Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/compileArg.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)

open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
open Js_of_ocaml_compiler.Stdlib
open Cmdliner

type t =
Expand Down Expand Up @@ -248,7 +248,7 @@ let options =
else None
in
let source_map =
if source_map <> None && not Source_map_io.enabled
if Option.is_some source_map && not Source_map_io.enabled
then (
warn
"Warning: '--source-map' flag ignored because js_of_ocaml was compiled \
Expand Down
14 changes: 8 additions & 6 deletions compiler/js_of_ocaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)

open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
open Js_of_ocaml_compiler.Stdlib

let times = Debug.find "times"

Expand Down Expand Up @@ -133,14 +133,16 @@ let f
in
if times () then Format.eprintf "Start parsing...@.";
let need_debug =
if source_map <> None || Config.Flag.debuginfo () || toplevel
if Option.is_some source_map || Config.Flag.debuginfo () || toplevel
then `Full
else if Config.Flag.pretty ()
then `Names
else `No
in
let check_debug debug =
if (not runtime_only) && source_map <> None && Parse_bytecode.Debug.is_empty debug
if (not runtime_only)
&& Option.is_some source_map
&& Parse_bytecode.Debug.is_empty debug
then
warn
"Warning: '--source-map' is enabled but the bytecode program was compiled with \
Expand Down Expand Up @@ -260,7 +262,7 @@ let f
| (`Stdout, _), false -> `Stdout
| (`Name x, _), false -> `Name x
| (`Name x, true), true
when String.length x > 0 && x.[String.length x - 1] = '/' ->
when String.length x > 0 && Char.equal x.[String.length x - 1] '/' ->
`Name (gen_unit_filename x cmo)
| (`Name _, true), true | (`Stdout, true), true ->
failwith "use [-o dirname/] or remove [--keep-unit-names]"
Expand All @@ -277,8 +279,8 @@ let f
match output_file with
| `Stdout, false -> `Name (gen_unit_filename "./" cmo)
| `Name x, false -> `Name (gen_unit_filename (Filename.dirname x) cmo)
| `Name x, true when String.length x > 0 && x.[String.length x - 1] = '/'
->
| `Name x, true
when String.length x > 0 && Char.equal x.[String.length x - 1] '/' ->
`Name (gen_unit_filename x cmo)
| `Stdout, true | `Name _, true ->
failwith "use [-o dirname/] or remove [--keep-unit-names]"
Expand Down
1 change: 1 addition & 0 deletions compiler/jsoo_link.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)

open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler

let f {LinkerArg.output_file; source_map; resolve_sourcemap_url; js_files} =
Expand Down
2 changes: 1 addition & 1 deletion compiler/jsoo_minify.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)

open! Js_of_ocaml_compiler.Stdlib
open Js_of_ocaml_compiler
open Js_of_ocaml_compiler.Stdlib

let error k = Format.ksprintf (fun s -> failwith s) k

Expand Down
10 changes: 6 additions & 4 deletions compiler/lib/base64.ml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*
*)

open! Stdlib

type ('a, 'b) result =
| Ok of 'a
| Error of 'b
Expand Down Expand Up @@ -51,9 +53,9 @@ let make_alphabet alphabet =
if String.length alphabet <> 64 then invalid_arg "Length of alphabet must be 64";
if String.contains alphabet '='
then invalid_arg "Alphabet can not contain padding character";
let emap = Array.init (String.length alphabet) (fun i -> Char.code alphabet.[i]) in
let emap = Array.init (String.length alphabet) ~f:(fun i -> Char.code alphabet.[i]) in
let dmap = Array.make 256 none in
String.iteri (fun idx chr -> dmap.(Char.code chr) <- idx) alphabet;
String.iteri ~f:(fun idx chr -> dmap.(Char.code chr) <- idx) alphabet;
{emap; dmap}

let length_alphabet {emap; _} = Array.length emap
Expand Down Expand Up @@ -146,7 +148,7 @@ let encode_sub pad {emap; _} ?(off = 0) ?len input =

let encode ?(pad = true) ?(alphabet = default_alphabet) ?off ?len input =
match encode_sub pad alphabet ?off ?len input with
| Ok (res, off, len) -> Ok (String.sub res off len)
| Ok (res, off, len) -> Ok (String.sub res ~pos:off ~len)
| Error _ as err -> err

let encode_string ?pad ?alphabet input =
Expand Down Expand Up @@ -284,7 +286,7 @@ let decode_sub ?(pad = true) {dmap; _} ?(off = 0) ?len input =

let decode ?pad ?(alphabet = default_alphabet) ?off ?len input =
match decode_sub ?pad alphabet ?off ?len input with
| Ok (res, off, len) -> Ok (String.sub res off len)
| Ok (res, off, len) -> Ok (String.sub res ~pos:off ~len)
| Error _ as err -> err

let decode_sub ?pad ?(alphabet = default_alphabet) ?off ?len input =
Expand Down
8 changes: 2 additions & 6 deletions compiler/lib/build_path_prefix_map.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
(* *)
(**************************************************************************)

open Stdlib
open! Stdlib

type path = string

Expand Down Expand Up @@ -107,11 +107,7 @@ let decode_map str =
let rewrite_opt prefix_map path =
let is_prefix = function
| None -> false
| Some {target = _; source} ->
String.length source <= String.length path
&& Stdlib.String.equal
source
(String.sub path ~pos:0 ~len:(String.length source))
| Some {target = _; source} -> String.is_prefix path ~prefix:source
in
match
List.find
Expand Down
16 changes: 10 additions & 6 deletions compiler/lib/code.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open Stdlib
open! Stdlib

module Addr = struct
type t = int
Expand Down Expand Up @@ -57,6 +57,8 @@ module Var : sig

val print : Format.formatter -> t -> unit

val equal : t -> t -> bool

val idx : t -> int

val of_idx : int -> t
Expand Down Expand Up @@ -128,7 +130,9 @@ end = struct
module T = struct
type t = int

let compare v1 v2 = v1 - v2
let compare : t -> t -> int = compare

let equal (a : t) (b : t) = a = b
end

include T
Expand Down Expand Up @@ -564,9 +568,9 @@ let eq (pc1, blocks1, _) (pc2, blocks2, _) =
&&
try
let block2 = Addr.Map.find pc blocks2 in
block1.params = block2.params
&& block1.branch = block2.branch
&& block1.body = block2.body
Poly.(block1.params = block2.params)
&& Poly.(block1.branch = block2.branch)
&& Poly.(block1.body = block2.body)
with Not_found -> false)
blocks1
true
Expand All @@ -586,7 +590,7 @@ let invariant (_, blocks, _) =
let define x =
if check_defs
then (
assert (defs.(Var.idx x) = false);
assert (not defs.(Var.idx x));
defs.(Var.idx x) <- true)
in
let check_expr = function
Expand Down
2 changes: 2 additions & 0 deletions compiler/lib/code.mli
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ module Var : sig

val print : Format.formatter -> t -> unit

val equal : t -> t -> bool

val idx : t -> int

val of_idx : int -> t
Expand Down
5 changes: 3 additions & 2 deletions compiler/lib/config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)

open Stdlib
open! Stdlib

module Flag = struct
let optims = ref []
Expand Down Expand Up @@ -137,7 +137,8 @@ module Param = struct

let tc_default = TcTrampoline

let _tc_all = tc_default :: List.filter [TcNone; TcTrampoline] ~f:(( <> ) tc_default)
let _tc_all =
tc_default :: List.filter [TcNone; TcTrampoline] ~f:(Poly.( <> ) tc_default)

let tailcall_optim =
p
Expand Down
2 changes: 2 additions & 0 deletions compiler/lib/constant.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)

open! Stdlib

let global_object = "joo_global_object"

let extra_js_files = ["+graphics.js"; "+toplevel.js"; "+nat.js"; "+dynlink.js"]
2 changes: 1 addition & 1 deletion compiler/lib/control.ml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
(*
FIX: is there a way to merge this with dead code elimination?
*)

open! Stdlib
open Code

(****)
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/deadcode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open Stdlib
open! Stdlib

let debug = Debug.find "deadcode"

Expand Down
4 changes: 2 additions & 2 deletions compiler/lib/debug.ml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)

open Stdlib
open! Stdlib

let series = ref None

Expand Down Expand Up @@ -55,7 +55,7 @@ let find s =
state
in
fun () ->
if s = "times" then take_snapshot ();
if String.equal s "times" then take_snapshot ();
(not !quiet) && !state

let enable s =
Expand Down
3 changes: 2 additions & 1 deletion compiler/lib/dgraph.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open! Stdlib

module Make (N : sig
type t
Expand Down Expand Up @@ -187,7 +188,7 @@ struct
let invert size g =
let h = NTbl.make size [] in
NSet.iter (fun x -> g.iter_children (fun y -> add_edge h y x) x) g.domain;
{domain = g.domain; iter_children = (fun f x -> List.iter f (successors h x))}
{domain = g.domain; iter_children = (fun f x -> List.iter ~f (successors h x))}

module type DOMAIN = sig
type t
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/driver.ml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)
open Stdlib
open! Stdlib

let debug = Debug.find "main"

Expand Down
Loading