Commit 44bf9263 authored by Pietro Abate's avatar Pietro Abate

[r2005-03-22 17:20:57 by afrisch] Empty log message

Original author: afrisch
Date: 2005-03-22 17:20:57+00:00
parent 160bc85f
......@@ -47,6 +47,8 @@ SRC= \
compile/lambda.ml \
runtime/value.mli \
runtime/value.ml \
runtime/run_dispatch.mli \
runtime/run_dispatch.ml \
runtime/serial.mli \
runtime/serial.ml
......
module T = Custom.Array(Custom.Pair(Types)(Custom.List(Patterns.Node)))
module P = struct
let () = Types.CompUnit.enter (Types.CompUnit.mk (Encodings.Utf8.mk "OCAML"))
let pms = ref [] and nb_pms = ref (-1)
let init () = pms:=[]; nb_pms:=0
let init () = pms:=[]; nb_pms:=(-1)
let mk () =
let pms = Array.of_list !pms in
Serialize.Put.run T.serialize pms
......@@ -12,7 +14,40 @@ module P = struct
end
module G = struct
type chunk = T.t
let mk s = Serialize.Get.run T.deserialize s
let pm x i = x.(i)
type chunk =
T.t *
(Patterns.Compile.dispatcher * int Patterns.Compile.rhs array)
option array
let mk s =
try
let a = Serialize.Get.run T.deserialize s in
(a, Array.create (Array.length a) None)
with _ -> assert false
let disp (spec,d) i =
match d.(i) with
| Some x -> x
| None ->
let (t,brs) = spec.(i) in
let brs =
Array.to_list (Array.mapi (fun i x -> (x,i)) (Array.of_list brs))
in
let x = Patterns.Compile.make_branches t brs in
d.(i) <- Some x;
x
let run (chunk : chunk) i v =
let (d,rhs) = disp chunk i in
let (code,bindings) = Run_dispatch.run_dispatcher d v in
match rhs.(code) with
| Patterns.Compile.Fail -> assert false
| Patterns.Compile.Match (bind,i) ->
i,
Array.map
(fun (_,i) -> if (i == -1) then v else bindings.(i))
(Array.of_list bind)
end
......@@ -9,5 +9,7 @@ module G : sig
type chunk
val mk: string -> chunk
val pm: chunk -> int -> Types.t * Patterns.Node.t list
val run: chunk -> int -> Value.t -> int * Value.t array
end
......@@ -99,8 +99,17 @@ runtime/value.cmo: types/atoms.cmi types/chars.cmi misc/encodings.cmi \
runtime/value.cmx: types/atoms.cmx types/chars.cmx misc/encodings.cmx \
types/ident.cmx types/intervals.cmx compile/lambda.cmx misc/ns.cmx \
types/sequence.cmx types/types.cmx runtime/value.cmi
runtime/serial.cmi: types/patterns.cmi types/types.cmi
runtime/serial.cmo: types/patterns.cmi misc/serialize.cmi types/types.cmi \
runtime/run_dispatch.cmi: types/patterns.cmi runtime/value.cmi
runtime/run_dispatch.cmo: types/atoms.cmi types/chars.cmi misc/encodings.cmi \
types/ident.cmo types/patterns.cmi types/types.cmi runtime/value.cmi \
runtime/run_dispatch.cmi
runtime/run_dispatch.cmx: types/atoms.cmx types/chars.cmx misc/encodings.cmx \
types/ident.cmx types/patterns.cmx types/types.cmx runtime/value.cmx \
runtime/run_dispatch.cmi
runtime/serial.cmi: types/patterns.cmi types/types.cmi runtime/value.cmi
runtime/serial.cmo: misc/custom.cmo types/patterns.cmi \
runtime/run_dispatch.cmi misc/serialize.cmi types/types.cmi \
runtime/serial.cmi
runtime/serial.cmx: types/patterns.cmx misc/serialize.cmx types/types.cmx \
runtime/serial.cmx: misc/custom.cmx types/patterns.cmx \
runtime/run_dispatch.cmx misc/serialize.cmx types/types.cmx \
runtime/serial.cmi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment