X-Git-Url: https://scm.cri.mines-paristech.fr/git/Faustine.git/blobdiff_plain/1878a8448a5a73cbf289306beb5e88ab48561129..440ca0ba93966e89b68dc54207c461afc0d56264:/interpretor/types.ml diff --git a/interpretor/types.ml b/interpretor/types.ml index 5c2c29d..ba61990 100644 --- a/interpretor/types.ml +++ b/interpretor/types.ml @@ -1,10 +1,49 @@ -type value = N of int + +type index = int;; + +type time = int;; + +type basic = N of int | R of float - | Vec of int * (int -> value) + | Vec of vector | Zero - | W + | Error +and vector = < size : int; nth : (index -> basic) >;; + +class type vector_type = + object + method size : int + method nth : index -> basic + end;; + +class type value_type = + object + method get : basic + method to_int : int + method to_float : float + method to_float_array : float array + method to_string : string + method normalize : unit + method add : value_type -> value_type + method neg : value_type + method sub : value_type -> value_type + method mul : value_type -> value_type + method recip : value_type + method div : value_type -> value_type + method zero : value_type + method floor : value_type + method int : value_type + method sin : value_type + method cos : value_type + method atan : value_type + method sqrt : value_type + method atan2 : value_type -> value_type + method _mod : value_type -> value_type + method larger : value_type -> value_type + method smaller : value_type -> value_type + end;; + -(** type symbol, defines valid identifiers in faust expressions.*) type symbol = Add | Sup | Mul @@ -23,8 +62,8 @@ type symbol = Add | Rdtable | Mod | Vectorize - | Concat - | Nth + | Vconcat + | Vpick | Serialize | Larger | Smaller @@ -32,45 +71,9 @@ type symbol = Add | Selecttwo | Selectthree -exception Symbol_not_defined;; - -let symbol_of_string = fun s -> - match s with - |"+" -> Add - |"-" -> Sup - |"*" -> Mul - |"/" -> Div - |"_" -> Pass - |"!" -> Stop - |"mem" -> Mem - |"@" -> Delay - |"floor" -> Floor - |"int" -> Int - |"sin" -> Sin - |"cos" -> Cos - |"atan" -> Atan - |"atantwo" -> Atantwo - |"sqrt" -> Sqrt - |"rdtable" -> Rdtable - |"%" -> Mod - |"vectorize" -> Vectorize - |"#" -> Concat - |"[]" -> Nth - |"serialize" -> Serialize - |">" -> Larger - |"<" -> Smaller - |"prefix" -> Prefix - |"selecttwo" -> Selecttwo - |"selectthree" -> Selectthree - | _ -> raise Symbol_not_defined - - - -type signal = int * (int -> value) - type faust_exp = - Const of value + Const of basic | Ident of symbol | Par of faust_exp * faust_exp | Seq of faust_exp * faust_exp @@ -79,5 +82,61 @@ type faust_exp = | Merge of faust_exp * faust_exp -type dimension = End of (int * int) - | Tree of (int * int) * (dimension * dimension) +class type signal_type = + object + method frequency : int + method at : time -> value_type + method add : signal_type -> signal_type + method neg : signal_type + method sub : signal_type -> signal_type + method mul : signal_type -> signal_type + method div : signal_type -> signal_type + method delay : signal_type -> signal_type + method mem : signal_type + method vectorize : signal_type -> signal_type + method serialize : signal_type + method vconcat : signal_type -> signal_type + method vpick : signal_type -> signal_type + method floor : signal_type + method int : signal_type + method sin : signal_type + method cos : signal_type + method atan : signal_type + method atan2 : signal_type -> signal_type + method sqrt : signal_type + method _mod : signal_type -> signal_type + method larger : signal_type -> signal_type + method smaller : signal_type -> signal_type + method rdtable : signal_type -> signal_type -> signal_type + method select2 : signal_type -> signal_type -> signal_type + method select3 : signal_type -> signal_type -> signal_type -> signal_type + method prefix : signal_type -> signal_type + end;; + + +class type beam_type = + object + method length : int + method sub : start: int -> length: int -> beam_type + method append : beam_type -> beam_type + method matching : size: int -> beam_type + method time : time -> basic list + method output : length: int -> (int list) * (float array list) + end;; + + +class type dimension_type = + object + method input : int + method output : int + end;; + + +class type expression_type = + object + method get_exp : faust_exp + method get_dim : dimension_type + method get_delay : int + method to_string : string + method evaluate : beam_type -> beam_type + end;;