Bug fixed for unix error "readlink /proc/self/fd/0" on MacOS.
[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 open Nest;;
11
12 let convert : (basic -> 'a) -> basic -> 'a =
13 fun oper -> fun b -> oper b;;
14
15 class value : basic -> value_type =
16 fun (b_init : basic) ->
17 object (self)
18 val mutable b = b_init
19 method get = b
20 method normalize = b <- basic_normalize self#get
21
22 method to_float = convert basic_to_float self#get
23 method to_int = convert basic_to_int self#get
24 method to_float_array = convert basic_to_float_array self#get
25 method to_string = convert basic_to_string self#get
26 method to_neststring = convert basic_to_neststring self#get
27 method of_float_array : float array -> value_type =
28 fun data -> new value (basic_of_float_array data)
29
30 method private prim1 : (basic -> basic) -> value =
31 fun oper ->
32 new value (oper self#get)
33
34 method neg = self#prim1 basic_neg
35 method recip = self#prim1 basic_recip
36 method zero = self#prim1 basic_zero
37 method floor = self#prim1 basic_floor
38 method ceil = self#prim1 basic_ceil
39 method rint = self#prim1 basic_rint
40 method int = self#prim1 basic_int
41 method float = self#prim1 basic_float
42 method sin = self#prim1 basic_sin
43 method asin = self#prim1 basic_asin
44 method cos = self#prim1 basic_cos
45 method acos = self#prim1 basic_acos
46 method tan = self#prim1 basic_tan
47 method atan = self#prim1 basic_atan
48 method exp = self#prim1 basic_exp
49 method sqrt = self#prim1 basic_sqrt
50 method ln = self#prim1 basic_ln
51 method lg = self#prim1 basic_lg
52 method abs = self#prim1 basic_abs
53
54 method private prim2 : (basic -> basic -> basic) -> value -> value =
55 fun oper ->
56 fun v ->
57 new value (oper self#get v#get)
58
59 method add = self#prim2 basic_add
60 method sub = self#prim2 basic_sub
61 method mul = self#prim2 basic_mul
62 method div = self#prim2 basic_div
63 method power = self#prim2 basic_power
64 method _and = self#prim2 basic_and
65 method _or = self#prim2 basic_or
66 method _xor = self#prim2 basic_xor
67 method _mod = self#prim2 basic_mod
68 method fmod = self#prim2 basic_fmod
69 method remainder = self#prim2 basic_remainder
70 method gt = self#prim2 basic_gt
71 method lt = self#prim2 basic_lt
72 method geq = self#prim2 basic_geq
73 method leq = self#prim2 basic_leq
74 method eq = self#prim2 basic_eq
75 method neq = self#prim2 basic_neq
76 method atan2 = self#prim2 basic_atan2
77 method max = self#prim2 basic_max
78 method min = self#prim2 basic_min
79 method shl = self#prim2 basic_shl
80 method shr = self#prim2 basic_shr
81
82 end;;
83