Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
bobzhang committed Aug 6, 2016
1 parent 6b9806e commit b1e23bc
Showing 1 changed file with 22 additions and 18 deletions.
40 changes: 22 additions & 18 deletions jscomp/type_util.ml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,16 @@

(* exception Path_not_found *)

let rec query (v : Path.t) (env : Env.t) : Types.signature option =
match Env.find_modtype_expansion v env with
| Mty_alias v1
| Mty_ident v1 -> query v1 env
| Mty_functor _ -> assert false (* not handled in FFI Yet*)
| Mty_signature s -> Some s
| exception _ -> None
(* let rec query (v : Path.t) (env : Env.t) : Types.signature option = *)
(* match Env.find_modtype_expansion v env with *)
(* | Mty_alias v1 *)
(* | Mty_ident v1 -> query v1 env *)
(* | Mty_functor _ -> assert false (\* not handled in FFI Yet*\) *)
(* | Mty_signature s -> Some s *)
(* | exception _ -> None *)

(* let string_of_value_description id = *)
(* Format.asprintf "%a" (Printtyp.value_description id) *)


let name_of_signature_item (x : Types.signature_item )=
Expand All @@ -56,12 +59,9 @@ let name_of_signature_item (x : Types.signature_item )=

(** Used in [Pgetglobal] *)
let get_name (serializable_sigs : Types.signature) (pos : int) =
let ident =
name_of_signature_item @@ List.nth serializable_sigs pos
in ident.name
Ident.name @@ name_of_signature_item @@ List.nth serializable_sigs pos


let string_of_value_description id =
Format.asprintf "%a" (Printtyp.value_description id)

(** It should be safe to replace Pervasives[],
we should test cases like module Pervasives = List *)
Expand Down Expand Up @@ -120,11 +120,15 @@ let find_name id pos env =

let pervasives_ident = Ident.create_persistent "Pervasives"

let pervasives_slots = lazy
match find_serializable_signatures_by_path pervasives_ident env with

let pervasives_slots env = lazy
(match find_serializable_signatures_by_path pervasives_ident env with
| Some signatures
->
List.fold_left (fun (i, acc) ->
if
)
| None -> None
Some (List.fold_left (fun (i, acc) s ->
if serializable_signature s then
(i + 1, Int_map.add i (name_of_signature_item s) acc)
else
i, acc
) (0, Int_map.empty) signatures)
| None -> None)

0 comments on commit b1e23bc

Please sign in to comment.