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
5 changes: 0 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@ jobs:
os:
- ubuntu-latest
ocaml-compiler:
- "4.08"
- "4.09"
- "4.10"
- "4.11"
- "4.12"
- "4.13"
- "5.0"
- "5.1"
Expand Down
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# dev

## Features/Changes
* Misc: drop support for OCaml 4.12 and bellow
* Compiler: use a Wasm text files preprocessor (#1822)
* Compiler: support for OCaml 4.14.3+trunk (#1844)
* Runtime: use es6 class (#1840)
Expand Down
4 changes: 0 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,4 @@ opam install odoc lwt_log yojson ocp-indent graphics higlo

### Running the tests

Tests are maintained for a single version of the OCaml compiler (currently 4.13).

Make sure to use the correct opam switch (e.g. `opam switch 4.13.1`).

Run `make tests`.
6 changes: 3 additions & 3 deletions compiler/bin-js_of_ocaml/check_runtime.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ open Js_of_ocaml_compiler

let group_by_snd l =
l
|> List.sort_uniq ~compare:(fun (n1, l1) (n2, l2) ->
|> List.sort_uniq ~cmp:(fun (n1, l1) (n2, l2) ->
match Poly.compare l1 l2 with
| 0 -> String.compare n1 n2
| c -> c)
Expand All @@ -49,8 +49,8 @@ let f (runtime_files, bytecode, target_env) =
let runtime_files, builtin =
List.partition_map runtime_files ~f:(fun name ->
match Builtins.find name with
| Some t -> `Snd t
| None -> `Fst name)
| Some t -> Right t
| None -> Left name)
in
let builtin =
if false then builtin else Js_of_ocaml_compiler_runtime_files.runtime @ builtin
Expand Down
7 changes: 4 additions & 3 deletions compiler/bin-js_of_ocaml/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ let sourcemap_section_of_info
| Some _ -> Filename.concat "/builtin" filename)
in
let ignore_list =
List.filter sources ~f:(fun filename -> String.is_prefix ~prefix:"/builtin/" filename)
List.filter sources ~f:(fun filename ->
String.starts_with ~prefix:"/builtin/" filename)
in
let offset, mappings = Source_map.Mappings.encode_with_offset mappings in
let map =
Expand Down Expand Up @@ -207,8 +208,8 @@ let run
let runtime_files, builtin =
List.partition_map runtime_files ~f:(fun name ->
match Builtins.find name with
| Some t -> `Snd t
| None -> `Fst name)
| Some t -> Right t
| None -> Left name)
in
let t1 = Timer.make () in
let builtin =
Expand Down
4 changes: 2 additions & 2 deletions compiler/bin-wasm_of_ocaml/compile.ml
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ let run
let runtime_js_files, builtin =
List.partition_map runtime_js_files ~f:(fun name ->
match Builtins.find name with
| Some t -> `Snd t
| None -> `Fst name)
| Some t -> Right t
| None -> Left name)
in
let t1 = Timer.make () in
let builtin = Js_of_ocaml_compiler_runtime_files.runtime @ builtin in
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib-runtime-files/gen/gen.ml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ let () =
match Array.to_list Sys.argv with
| [] -> assert false
| _ :: rest ->
let rest = List.sort_uniq ~compare:String.compare rest in
let rest = List.sort_uniq ~cmp:String.compare rest in
let fragments =
List.map rest ~f:(fun f -> f, Js_of_ocaml_compiler.Linker.Fragment.parse_file f)
in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ let runtime =
; hash
; ieee_754
; int64
; internalMod
; ints
; io
; jslib
Expand Down
8 changes: 4 additions & 4 deletions compiler/lib-runtime-files/tests/all.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ let%expect_test _ =
+hash.js
+ieee_754.js
+int64.js
+internalMod.js
+ints.js
+io.js
+jslib.js
Expand All @@ -51,7 +50,8 @@ let%expect_test _ =
+toplevel.js
+unix.js
+weak.js
+zstd.js |}];
+zstd.js
|}];
printl runtime;
[%expect
{|
Expand All @@ -73,7 +73,6 @@ let%expect_test _ =
+hash.js
+ieee_754.js
+int64.js
+internalMod.js
+ints.js
+io.js
+jslib.js
Expand All @@ -93,7 +92,8 @@ let%expect_test _ =
+sys.js
+unix.js
+weak.js
+zstd.js |}];
+zstd.js
|}];
printl extra;
[%expect {|
+dynlink.js
Expand Down
4 changes: 2 additions & 2 deletions compiler/lib/build_path_prefix_map.ml
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,15 @@ let decode_map str =
| Ok str -> Some str
| Error err -> raise (Shortcut err))
in
let pairs = String.split_char ~sep:':' str in
let pairs = String.split_on_char ~sep:':' str in
match List.map ~f:decode_or_empty pairs with
| exception Shortcut err -> Error err
| map -> Ok map

let rewrite_opt prefix_map path =
let is_prefix = function
| None -> false
| Some { target = _; source } -> String.is_prefix path ~prefix:source
| Some { target = _; source } -> String.starts_with path ~prefix:source
in
match
List.find
Expand Down
4 changes: 2 additions & 2 deletions compiler/lib/generate.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1464,7 +1464,7 @@ let rec translate_expr ctx loc x e level : (_ * J.statement_list) Expr_builder.t
match internal_prim name with
| Some f -> f l ctx loc
| None ->
if String.is_prefix name ~prefix:"%"
if String.starts_with name ~prefix:"%"
then failwith (Printf.sprintf "Unresolved internal primitive: %s" name);
let prim = Share.get_prim (runtime_fun ctx) name ctx.Ctx.share in
let* () = info ~need_loc:true (kind (Primitive.kind name)) in
Expand Down Expand Up @@ -1522,7 +1522,7 @@ and translate_instr ctx expr_queue loc instr =
(* "switcher" is emitted by the OCaml compiler when compiling
pattern matching, it does not help much to keep it in the
generated js, let's drop it *)
(not (generated_name s)) && not (String.is_prefix s ~prefix:"jsoo_")
(not (generated_name s)) && not (String.starts_with s ~prefix:"jsoo_")
in
match ctx.Ctx.live.(Var.idx x), e with
| 0, _ ->
Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/javascript.ml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ end = struct

let to_targetint s =
if
String.is_prefix s ~prefix:"0"
String.starts_with s ~prefix:"0"
&& String.length s > 1
&& String.for_all s ~f:(function
| '0' .. '7' -> true
Expand Down
3 changes: 2 additions & 1 deletion compiler/lib/js_output.ml
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,8 @@ struct
for i = 0 to l - 1 do
let c = s.[i] in
match c with
| '\000' when i = l - 1 || not (Char.is_num s.[i + 1]) -> Buffer.add_string b "\\0"
| '\000' when i = l - 1 || not (Char.is_digit s.[i + 1]) ->
Buffer.add_string b "\\0"
| '\b' (* 008 *) -> Buffer.add_string b "\\b"
| '\t' (* 009 *) -> Buffer.add_string b "\\t"
| '\n' (* 010 *) -> Buffer.add_string b "\\n"
Expand Down
6 changes: 3 additions & 3 deletions compiler/lib/link_js.ml
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ type action =
| Source_map of Source_map.t

let prefix_kind line =
match String.is_prefix ~prefix:info_prefix line with
match String.starts_with ~prefix:info_prefix line with
| false -> `Other
| true -> (
match String.is_prefix ~prefix:sourceMappingURL line with
match String.starts_with ~prefix:sourceMappingURL line with
| false -> (
match Build_info.parse line with
| Some bi -> `Build_info bi
Expand All @@ -142,7 +142,7 @@ let prefix_kind line =
| Some _ -> `Unit
| None -> `Other))
| true -> (
match String.is_prefix ~prefix:sourceMappingURL_base64 line with
match String.starts_with ~prefix:sourceMappingURL_base64 line with
| true -> `Json_base64 (String.length sourceMappingURL_base64)
| false -> `Url (String.length sourceMappingURL)))

Expand Down
2 changes: 1 addition & 1 deletion compiler/lib/linker.ml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module Check = struct
(fun x acc ->
match x with
| S { name = Utf8_string.Utf8 s; _ } ->
if String.is_prefix s ~prefix:"_" || String.equal s name
if String.starts_with s ~prefix:"_" || String.equal s name
then acc
else s :: acc
| V _ -> acc)
Expand Down
9 changes: 2 additions & 7 deletions compiler/lib/magic_number.ml
Original file line number Diff line number Diff line change
Expand Up @@ -67,20 +67,15 @@ let equal a b = compare a b = 0
let v =
let current = Ocaml_version.current in
match current with
| 4 :: 08 :: _ -> 25
| 4 :: 09 :: _ -> 26
| 4 :: 10 :: _ -> 27
| 4 :: 11 :: _ -> 28
| 4 :: 12 :: _ -> 29
| 4 :: 13 :: _ -> 30
| 4 :: 14 :: _ -> 31
| 5 :: 00 :: _ -> 32
| 5 :: 01 :: _ -> 33
| 5 :: 02 :: _ -> 34
| 5 :: 03 :: _ -> 35
| _ ->
if Ocaml_version.compare current [ 4; 8 ] < 0
then failwith "OCaml version unsupported. Upgrade to OCaml 4.08 or newer."
if Ocaml_version.compare current [ 4; 13 ] < 0
then failwith "OCaml version unsupported. Upgrade to OCaml 4.13 or newer."
else (
assert (Ocaml_version.compare current [ 5; 4 ] >= 0);
failwith "OCaml version unsupported. Upgrade js_of_ocaml.")
Expand Down
5 changes: 1 addition & 4 deletions compiler/lib/ocaml_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ let rec constant_of_const c : Code.constant =
match c with
| Const_base (Const_int i) -> Int (Targetint.of_int_warning_on_overflow i)
| Const_base (Const_char c) -> Int (Targetint.of_int_exn (Char.code c))
| ((Const_base (Const_string (s, _))) [@if ocaml_version < (4, 11, 0)])
| ((Const_base (Const_string (s, _, _))) [@if ocaml_version >= (4, 11, 0)]) -> String s
| Const_base (Const_string (s, _, _)) -> String s
| Const_base (Const_float s) -> Float (float_of_string s)
| Const_base (Const_int32 i) -> (
match Config.target () with
Expand All @@ -40,8 +39,6 @@ let rec constant_of_const c : Code.constant =
| Const_float_array sl ->
let l = List.map ~f:(fun f -> float_of_string f) sl in
Float_array (Array.of_list l)
| ((Const_pointer i) [@if ocaml_version < (4, 12, 0)]) ->
Int (Targetint.of_int_warning_on_overflow i)
| Const_block (tag, l) ->
let l = Array.of_list (List.map l ~f:constant_of_const) in
Tuple (tag, l, Unknown)
Expand Down
Loading
Loading