Fix the preprocessor compiling bug in interpretor/Makefile.
[Faustine.git] / interpretor / 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 int = self#prim1 basic_int
37 method sin = self#prim1 basic_sin
38 method cos = self#prim1 basic_cos
39 method atan = self#prim1 basic_atan
40 method sqrt = self#prim1 basic_sqrt
41
42 method private prim2 : (basic -> basic -> basic) -> value -> value =
43 fun oper ->
44 fun v ->
45 new value (oper self#get v#get)
46
47 method add = self#prim2 basic_add
48 method sub = self#prim2 basic_sub
49 method mul = self#prim2 basic_mul
50 method div = self#prim2 basic_div
51 method atan2 = self#prim2 basic_atan2
52 method _mod = self#prim2 basic_mod
53 method larger = self#prim2 basic_larger
54 method smaller = self#prim2 basic_smaller
55 method max = self#prim2 basic_max
56 method min = self#prim2 basic_min
57
58 end;;
59