Create a new library symbol.ml.
[Faustine.git] / interpretor / symbol.ml
diff --git a/interpretor/symbol.ml b/interpretor/symbol.ml
new file mode 100644 (file)
index 0000000..68f5d5f
--- /dev/null
@@ -0,0 +1,75 @@
+(**
+       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 vectorize_memory_length = 1000;;
+
+let dimension_of_symbol : symbol -> int * int =
+  fun (s : symbol) ->
+    match s with
+    |Add        ->  (2, 1)
+    |Sub        ->  (2, 1)             
+    |Mul        ->  (2, 1)
+    |Div        ->  (2, 1)
+    |Pass       ->  (1, 1)
+    |Stop       ->  (1, 0)
+    |Mem        ->  (1, 1)
+    |Delay      ->  (2, 1)
+    |Floor      ->  (1, 1)
+    |Int        ->  (1, 1)
+    |Sin        ->  (1, 1)
+    |Cos        ->  (1, 1)
+    |Atan       ->  (1, 1)
+    |Atan2      ->  (2, 1)
+    |Sqrt       ->  (1, 1)
+    |Rdtable    ->  (3, 1)
+    |Mod        ->  (2, 1)
+    |Vectorize  ->  (2, 1)
+    |Vconcat    ->  (2, 1)
+    |Vpick      ->  (2, 1)
+    |Serialize  ->  (1, 1)
+    |Larger     ->  (2, 1)
+    |Smaller    ->  (2, 1)
+    |Prefix     ->  (2, 1)
+    |Select2    ->  (3, 1)
+    |Select3     ->  (4, 1);;
+
+let delay_of_symbol : symbol -> int =
+  fun (s : symbol) ->
+    match s with
+    |Add        ->     0
+    |Sub        ->     0               
+    |Mul        ->     0
+    |Div        ->     0
+    |Pass       ->     0
+    |Stop       ->     0
+    |Mem        ->     1
+    |Delay      ->     delay_memory_length 
+    |Floor      ->     0
+    |Int        ->     0
+    |Sin        ->     0
+    |Cos        ->     0
+    |Atan       ->     0
+    |Atan2      ->     0
+    |Sqrt       ->     0
+    |Rdtable    ->     rdtable_memory_length
+    |Mod        ->     0
+    |Larger     ->     0
+    |Smaller    ->     0
+    |Vectorize  ->     vectorize_memory_length
+    |Vconcat    ->     0
+    |Vpick      ->     0
+    |Serialize  ->     0
+    |Prefix     ->     1
+    |Select2    ->     0
+    |Select3     ->    0;;