X-Git-Url: https://scm.cri.mines-paristech.fr/git/Faustine.git/blobdiff_plain/4d5f39ea1ae1eff1d8eadf7875851be467e40a47..23922b6f3a5f9813b822b4c60f05c8f2e384b070:/interpretor/faustexp.ml diff --git a/interpretor/faustexp.ml b/interpretor/faustexp.ml index 684eb75..8ad37aa 100644 --- a/interpretor/faustexp.ml +++ b/interpretor/faustexp.ml @@ -6,12 +6,14 @@ *) open Types;; +open Basic;; open Value;; open Signal;; open Beam;; exception NotYetDone;; exception Dimension_error of string;; +exception Process_error of string;; class dimension : int * int -> dimension_type = fun (init : int * int) -> @@ -91,17 +93,51 @@ class process : faust_exp -> process_type = class proc_const : faust_exp -> process_type = fun (exp_init : faust_exp) -> object (self) - val exp = exp_init - val dim = - method evaluate = fun b1 -> - + val _exp = exp_init + val _dim = new dimension (0,1) + val _delay = 0 + val _const = + match exp_init with + | Const b -> b + | _ -> raise (Process_error "const process constructor.") + + method exp = _exp + method dim = _dim + method delay = _delay + method const = _const + + method eval : beam_type -> beam_type = + fun (input : beam_type) -> + if input = [||] then + new beam [| new signal 0 (fun t -> new value self#const)|] + else + raise (Process_error "proc_const accepts no input.") end;; -class exp_ident = - object - inherit expression - +class exp_ident : faust_exp -> process_type = + fun (exp_init : faust_exp) -> + object (self) + val _exp = exp_init + val _symbol = + match exp_init with + | Ident s -> s + | _ -> raise (Process_error "ident process constructor.") + val _dim = dimension_of_symbol _symbol + val _delay = 0 + + + method exp = _exp + method dim = _dim + method delay = _delay + method const = _const + + method eval : beam_type -> beam_type = + fun (input : beam_type) -> + if input = [||] then + new beam [| new signal 0 (fun t -> new value self#const)|] + else + raise (Process_error "proc_const accepts no input.") end;;