X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/440ca0ba93966e89b68dc54207c461afc0d56264..e1705e136ab823be2e76e63728db1a5359d5d443:/interpretor/beam.ml diff --git a/interpretor/beam.ml b/interpretor/beam.ml new file mode 100644 index 0000000..33fb08e --- /dev/null +++ b/interpretor/beam.ml @@ -0,0 +1,41 @@ +(** + Module: Beam + Description: beam definition and operations + @author WANG Haisheng + Created: 21/07/2013 Modified: 21/07/2013 +*) + +exception Beam_matching of string;; + +open Signal;; + +class beam : signal_type array -> beam_type = + fun (sa_init : signal_type array) -> + object (self) + val sa = sa_init + val l = Array.length sa + + method get = sa + + method length = l + + method sub : int -> int -> beam_type = + fun start -> + fun len -> + new beam (Array.sub self#get start len) + + method append : beam_type -> beam_type = + fun b -> + new beam (Array.append self#get b) + + method matching : int -> beam_type + fun size -> + if size = self#length then self + else if size > self#length && size mod self#length = 0 then + + else if size < self#length && self#length mod size = 0 then + + else raise (Beam_matching "matching size error") + + + end