Permalink
Browse files

port to ocaml 4.00.1 + ocamlopt

  • Loading branch information...
1 parent 8c3d08f commit daac09e5267dee8ff323bab5b57676bface02ca8 @camlspotter camlspotter committed Feb 14, 2013
Showing with 91 additions and 130 deletions.
  1. +5 −5 OMakefile
  2. +0 −58 config.ml
  3. +0 −8 config.mli
  4. +3 −3 controller.ml
  5. +2 −2 controller.mli
  6. +3 −3 main.ml
  7. +25 −6 search.ml
  8. +53 −45 searchid.ml
View
@@ -5,21 +5,21 @@ OCAMLPACKS[] =
extlib
CamlGI
str
-
+ compiler-libs.bytecomp
if $(not $(OCAMLFIND_EXISTS))
eprintln('This project requires ocamlfind, but is was not found.')
eprintln('You need to install ocamlfind and run "omake --configure".')
exit 1
-OCAMLFLAGS += -dtypes -g -thread
+OCAMLFLAGS += -dtypes -g -thread -w A-4-9 -warn-error A-4-6-9-27-31-33
OCAMLINCLUDES += ../parsing
OCAMLINCLUDES += ../typing
-NATIVE_ENABLED = false
+NATIVE_ENABLED = true
BYTE_ENABLED = true
FILES[] =
- config
+ chconfig
controller
hList
list2
@@ -32,7 +32,7 @@ PROGRAM = index.cgi
# OCAML_LIBS +=
# OCAML_CLIBS +=
-OCAML_OTHER_LIBS += toplevellib
+# OCAML_OTHER_LIBS += toplevellib
# OCAML_LIB_FLAGS +=
#
View
@@ -1,58 +0,0 @@
-open Base
-open Str
-type t = {
- name : string;
- path : string option;
- modules : string list
-}
-
-let name = ref ""
-let path = ref None
-let modules = ref []
-let configs = ref []
-
-let chop s =
- let r =
- regexp "[\r\n]"
- in
- global_replace r "" s
-
-let add_current () =
- if !name <> "" then
- configs := { name = !name; modules = List.rev !modules; path= !path } ::
- !configs;
- name := "";
- path := None;
- modules := []
-
-let r_package =
- regexp "^- *\\(.*\\)$"
-
-let r_path =
- regexp "^PATH *:: *\\(.*\\)$"
-
-let parse_line s =
- if s = "" then
- ()
- else if string_match r_path s 0 then
- path := Some (matched_group 1 s)
- else if string_match r_package s 0 then begin
- add_current ();
- name := matched_group 1 s
- end else
- modules := s :: !modules
-
-let read path =
- configs := [];
- name := "";
- try
- open_in_with path begin fun ch ->
- while true do
- parse_line @@ chop @@ input_line ch
- done;
- end;
- failwith "must not happen"
- with End_of_file ->
- add_current ();
- List.rev !configs
-
View
@@ -1,8 +0,0 @@
-type t = {
- name : string;
- path:string option;
- modules : string list
-}
-
-val read : string -> t list
-
View
@@ -9,9 +9,9 @@ type t =
let find_package module_ configs =
let config =
List.find configs
- ~f:(fun { Config.modules=modules } -> List.mem (List.hd module_) modules)
+ ~f:(fun { Chconfig.modules=modules } -> List.mem (List.hd module_) modules)
in
- config.Config.name
+ config.Chconfig.name
let module_ =
function [] -> [""]
@@ -92,7 +92,7 @@ let pagenation ~offset ~window xs =
let available configs =
Table begin
- List.map configs ~f:begin fun { Config.name = name; modules = modules} ->
+ List.map configs ~f:begin fun { Chconfig.name = name; modules = modules} ->
["package", String name;
"modules", Table begin
List.map modules ~f:begin fun s ->
View
@@ -3,6 +3,6 @@ type t =
| Bool of bool
| Table of (string * t) list list
-val format : Config.t list -> Search.t -> (string * t) list
+val format : Chconfig.t list -> Search.t -> (string * t) list
val pagenation : offset:int -> window:int -> 'a list -> (string * t) list * 'a list
-val available : Config.t list -> t
+val available : Chconfig.t list -> t
View
@@ -45,7 +45,7 @@ let index_page (cgi : cgi) =
cgi#template @@ template "templates/index.html"
let configs () =
- Config.read "modules.txt"
+ Chconfig.read "modules.txt"
let available_page (cgi : cgi) =
let t =
@@ -59,10 +59,10 @@ let search_page (cgi : cgi) =
configs ()
in
let modules =
- HList.concat_map (fun {Config.modules=m} -> m) configs
+ HList.concat_map (fun {Chconfig.modules=m} -> m) configs
in
let paths =
- filter_map (fun {Config.path=p} -> p) configs
+ filter_map (fun {Chconfig.path=p} -> p) configs
in
let page, content =
Search.search (cgi#param "q") modules paths
View
@@ -19,6 +19,25 @@ type t = {
let init_modules =
!Searchid.module_list
+module Toploop = struct
+ open Config
+ let set_paths () =
+ (* Add whatever -I options have been specified on the command line,
+ but keep the directories that user code linked in with ocamlmktop
+ may have added to load_path. *)
+ load_path := !load_path @ [Filename.concat Config.standard_library "camlp4"];
+ load_path := "" :: (List.rev !Clflags.include_dirs @ !load_path);
+ Dll.add_path !load_path
+end
+
+module Topdirs = struct
+ open Misc
+ let dir_directory s =
+ let d = expand_directory Config.standard_library s in
+ Config.load_path := d :: !Config.load_path;
+ Dll.add_path [d]
+end
+
let init modules paths =
(* initialize *)
Toploop.set_paths ();
@@ -45,23 +64,23 @@ let string_of_sign sign =
let string_of_value id =
let name =
match id with
- Longident.Lident x -> x
- | Longident.Ldot (_, x) -> x
+ Longident.Lident x -> x
+ | Longident.Ldot (_, x) -> x
| _ -> "z"
in
let _, vd =
Env.lookup_value id !Searchid.start_env
in
Str.replace_first (Str.regexp "=[^=]*$") "" @@
Str.replace_first (Str.regexp "^[^:]*: *") ""
- (string_of_sign [Types.Tsig_value (Ident.create name, vd)])
+ (string_of_sign [Types.Sig_value (Ident.create name, vd)])
let ident_of_path ~default = function
Path.Pident i -> i
| Path.Pdot (_, s, _) -> Ident.create s
| Path.Papply _ -> Ident.create default
-let dummy_item = Tsig_modtype (Ident.create "dummy", Tmodtype_abstract)
+let dummy_item = Sig_modtype (Ident.create "dummy", Modtype_abstract)
let string_of_type_decl path =
let td =
@@ -78,12 +97,12 @@ let string_of_type_decl path =
clt = Env.find_cltype path !Searchid.start_env
in
string_of_sign
- [Tsig_cltype (ident_of_path path ~default:"ct", clt, Trec_first);
+ [Sig_class_type (ident_of_path path ~default:"ct", clt, Trec_first);
dummy_item; dummy_item]
| _ -> raise Not_found
with Not_found ->
string_of_sign
- [Tsig_type(ident_of_path path ~default:"t", td, Trec_first)]
+ [Sig_type(ident_of_path path ~default:"t", td, Trec_first)]
let string_of_type id =
let strip s =
Oops, something went wrong.

0 comments on commit daac09e

Please sign in to comment.