Fix bugs during installation of libsndfile-ocaml.
[Faustine.git] / interpreter / value.ml
1 (**
2 Module: Value
3 Description: basic data type in the vectorial faust interpreter.
4 @author WANG Haisheng
5 Created: 31/05/2013 Modified: 17/07/2013
6 *)
7
8 open Types;;
9 open Basic;;
10
11 let convert : (basic -> 'a) -> basic -> 'a =
12 fun oper -> fun b -> oper b;;
13
14 class value : basic -> value_type =
15 fun (b_init : basic) ->
16 object (self)
17 val mutable b = b_init
18 method get = b
19 method normalize = b <- basic_normalize self#get
20
21 method to_float = convert basic_to_float self#get
22 method to_int = convert basic_to_int self#get
23 method to_float_array = convert basic_to_float_array self#get
24 method to_string = convert basic_to_string self#get
25 method of_float_array : float array -> value_type =
26 fun data -> new value (basic_of_float_array data)
27
28 method private prim1 : (basic -> basic) -> value =
29 fun oper ->
30 new value (oper self#get)
31
32 method neg = self#prim1 basic_neg
33 method recip = self#prim1 basic_recip
34 method zero = self#prim1 basic_zero
35 method floor = self#prim1 basic_floor
36 method ceil = self#prim1 basic_ceil
37 method rint = self#prim1 basic_rint
38 method int = self#prim1 basic_int
39 method float = self#prim1 basic_float
40 method sin = self#prim1 basic_sin
41 method asin = self#prim1 basic_asin
42 method cos = self#prim1 basic_cos
43 method acos = self#prim1 basic_acos
44 method tan = self#prim1 basic_tan
45 method atan = self#prim1 basic_atan
46 method exp = self#prim1 basic_exp
47 method sqrt = self#prim1 basic_sqrt
48 method ln = self#prim1 basic_ln
49 method lg = self#prim1 basic_lg
50 method abs = self#prim1 basic_abs
51
52 method private prim2 : (basic -> basic -> basic) -> value -> value =
53 fun oper ->
54 fun v ->
55 new value (oper self#get v#get)
56
57 method add = self#prim2 basic_add
58 method sub = self#prim2 basic_sub
59 method mul = self#prim2 basic_mul
60 method div = self#prim2 basic_div
61 method power = self#prim2 basic_power
62 method _and = self#prim2 basic_and
63 method _or = self#prim2 basic_or
64 method _xor = self#prim2 basic_xor
65 method _mod = self#prim2 basic_mod
66 method fmod = self#prim2 basic_fmod
67 method remainder = self#prim2 basic_remainder
68 method gt = self#prim2 basic_gt
69 method lt = self#prim2 basic_lt
70 method geq = self#prim2 basic_geq
71 method leq = self#prim2 basic_leq
72 method eq = self#prim2 basic_eq
73 method neq = self#prim2 basic_neq
74 method atan2 = self#prim2 basic_atan2
75 method max = self#prim2 basic_max
76 method min = self#prim2 basic_min
77 method shl = self#prim2 basic_shl
78 method shr = self#prim2 basic_shr
79
80 end;;
81