Adding new source file faustio.ml, including class waveio and class csvio.
[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
26 method private prim1 : (basic -> basic) -> value =
27 fun oper ->
28 new value (oper self#get)
29
30 method neg = self#prim1 basic_neg
31 method recip = self#prim1 basic_recip
32 method zero = self#prim1 basic_zero
33 method floor = self#prim1 basic_floor
34 method int = self#prim1 basic_int
35 method sin = self#prim1 basic_sin
36 method cos = self#prim1 basic_cos
37 method atan = self#prim1 basic_atan
38 method sqrt = self#prim1 basic_sqrt
39
40 method private prim2 : (basic -> basic -> basic) -> value -> value =
41 fun oper ->
42 fun v ->
43 new value (oper self#get v#get)
44
45 method add = self#prim2 basic_add
46 method sub = self#prim2 basic_sub
47 method mul = self#prim2 basic_mul
48 method div = self#prim2 basic_div
49 method atan2 = self#prim2 basic_atan2
50 method _mod = self#prim2 basic_mod
51 method larger = self#prim2 basic_larger
52 method smaller = self#prim2 basic_smaller
53
54 end;;
55