+exception NotYetDone;;
+exception Dimension_error of string;;
+exception Process_error of string;;
+
+class dimension : int * int -> dimension_type =
+ fun (init : int * int) ->
+ object (self)
+ val dim_input = fst init
+ val dim_output = snd init
+
+ method input = dim_input
+ method output = dim_output
+
+ method par : dimension_type -> dimension_type =
+ fun dim ->
+ new dimension
+ ((self#input + dim#input), (self#output + dim#output))
+
+ method seq : dimension_type -> dimension_type =
+ fun dim ->
+ if self#output = dim#input then
+ new dimension (self#input, dim#output)
+ else raise (Dimension_error "seq dimension not matched.")
+
+ method split : dimension_type -> dimension_type =
+ fun dim ->
+ if dim#input mod self#output = 0 then
+ new dimension (self#input, dim#output)
+ else raise (Dimension_error "split dimension not matched.")
+
+ method merge : dimension_type -> dimension_type =
+ fun dim ->
+ if self#output mod dim#input = 0 then
+ new dimension (self#input, dim#output)
+ else raise (Dimension_error "merge dimension not matched.")
+
+ method _rec : dimension_type -> dimension_type =
+ fun dim ->
+ if self#output >= dim#input && self#input >= dim#output then
+ new dimension (self#input - dim#output, self#output)
+ else raise (Dimension_error "rec dimension not matched.")
+ end;;
+
+class process : faust_exp -> process_type =
+ fun (exp_init : faust_exp) ->
+ object (self)
+ val exp = exp_init
+ val left =
+ match exp_init with
+ | Const b -> exp_init
+ | Ident s -> exp_init
+ | Par (e1, e2) -> e1
+ | Seq (e1, e2) -> e1
+ | Split (e1, e2) -> e1
+ | Merge (e1, e2) -> e1
+ | Rec (e1, e2) -> e1
+
+ val right =
+ match exp_init with
+ | Const b -> exp_init
+ | Ident s -> exp_init
+ | Par (e1, e2) -> e2
+ | Seq (e1, e2) -> e2
+ | Split (e1, e2) -> e2
+ | Merge (e1, e2) -> e2
+ | Rec (e1, e2) -> e2
+
+ val proc_left =
+
+ val dim = new dimension
+ val delay = 0
+ method get_exp = exp
+ method get_dim = dim
+ method get_delay = delay
+ method to_string = "NotYetDone"
+ method virtual evaluate : beam_type -> beam_type
+ end;;
+
+
+class proc_const : faust_exp -> process_type =
+ fun (exp_init : faust_exp) ->
+ object (self)
+ 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 : 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;;
+
+
+class exp_par =
+ object
+ inherit expression
+
+ end;;
+
+
+class exp_split =
+ object
+ inherit expression
+
+ end;;
+
+
+class exp_merge =
+ object
+ inherit expression
+
+ end;;
+
+class exp_seq =
+ object
+ inherit expression
+
+ end;;
+
+class exp_rec =
+ object
+ inherit expression
+
+ end;;
+
+*)