OOP initial commit with new traces.
[Faustine.git] / interpretor / beam.ml
1 (**
2 Module: Beam
3 Description: beam definition and operations
4 @author WANG Haisheng
5 Created: 21/07/2013 Modified: 21/07/2013
6 *)
7
8 exception Beam_matching of string;;
9
10 open Signal;;
11
12 class beam : signal_type array -> beam_type =
13 fun (sa_init : signal_type array) ->
14 object (self)
15 val sa = sa_init
16 val l = Array.length sa
17
18 method get = sa
19
20 method length = l
21
22 method sub : int -> int -> beam_type =
23 fun start ->
24 fun len ->
25 new beam (Array.sub self#get start len)
26
27 method append : beam_type -> beam_type =
28 fun b ->
29 new beam (Array.append self#get b)
30
31 method matching : int -> beam_type
32 fun size ->
33 if size = self#length then self
34 else if size > self#length && size mod self#length = 0 then
35
36 else if size < self#length && self#length mod size = 0 then
37
38 else raise (Beam_matching "matching size error")
39
40
41 end