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
3 changes: 3 additions & 0 deletions Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ Unreleased
[#658](https://github.com/melange-re/melange/issues/658))
- core: print lambda IR after TRMC pass when `--drawlambda` is passed
([#1072](https://github.com/melange-re/melange/pull/1072))
- core: remove unnecessary internal code from melange-compiler-libs, slimming
down the melange executable and speeding up the build
([#1075](https://github.com/melange-re/melange/pull/1075))

3.0.0 2024-01-28
---------------
Expand Down
4 changes: 1 addition & 3 deletions bin/melc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,7 @@ let apply_lazy ~source ~target =
output_value oc ast
| Impl ast ->
let ast: Ppxlib_ast__.Versions.OCaml_current.Ast.Parsetree.structure =
let ast: Melange_compiler_libs.Parsetree.structure =
apply ~kind:Ml_binary.Ml ast
in
let ast = apply ~kind:Ml_binary.Ml ast in
let ppxlib_ast: Melange_ast_version.Ast.Parsetree.structure =
Obj.magic ast
in
Expand Down
20 changes: 10 additions & 10 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions jscomp/common/lam_constant.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

open Import

type pointer_info =
| None
| Pt_constructor of {
Expand Down
2 changes: 0 additions & 2 deletions jscomp/common/lam_tag_info.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

open Import

(* Similiar to {!Lambda.tag_info}
In particular,
it reduces some branches e.g,
Expand Down
2 changes: 0 additions & 2 deletions jscomp/core/ast_config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

open Import

val add_structure : string -> (Parsetree.expression option -> unit) -> unit
val add_signature : string -> (Parsetree.expression option -> unit) -> unit
val iter_on_mel_config_stru : Parsetree.structure -> unit
Expand Down
14 changes: 8 additions & 6 deletions jscomp/core/ast_io.cppo.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ module type OCaml_version = Ppxlib_ast.OCaml_version

module Intf_or_impl = struct
type t =
| Intf of Melange_compiler_libs.Parsetree.signature
| Impl of Melange_compiler_libs.Parsetree.structure
| Intf of Parsetree.signature
| Impl of Parsetree.structure

module Convert =
Ppxlib_ast.Convert
Expand All @@ -49,15 +49,15 @@ module Intf_or_impl = struct
fun stru ->
let melange_stru =
let ocaml_51_stru = Convert.copy_structure stru in
(Obj.magic ocaml_51_stru : Melange_compiler_libs.Parsetree.structure)
(Obj.magic ocaml_51_stru : Parsetree.structure)
in
Impl melange_stru

let ppxlib_intf : Ppxlib_ast.Ast.signature -> t =
fun sig_ ->
let melange_sig =
let ocaml_51_sig = Convert.copy_signature sig_ in
(Obj.magic ocaml_51_sig : Melange_compiler_libs.Parsetree.signature)
(Obj.magic ocaml_51_sig : Parsetree.signature)
in
Intf melange_sig
end
Expand Down Expand Up @@ -126,7 +126,8 @@ let from_channel ch ~input_kind : (t, read_error) result =
match Find_version.from_magic s with
| Intf (module Input_version : OCaml_version) ->
let input_name : string = input_value ch in
Location.set_input_name input_name;
Ocaml_common.Location.input_name := input_name;
Location.input_name := input_name;
let ast = input_value ch in
let module Input_to_ppxlib =
Convert (Input_version) (Ppxlib_ast.Selected_ast)
Expand All @@ -140,7 +141,8 @@ let from_channel ch ~input_kind : (t, read_error) result =
}
| Impl (module Input_version : OCaml_version) ->
let input_name : string = input_value ch in
Location.set_input_name input_name;
Location.input_name := input_name;
Ocaml_common.Location.input_name := input_name;
let ast = input_value ch in
let module Input_to_ppxlib =
Convert (Input_version) (Ppxlib_ast.Selected_ast)
Expand Down
1 change: 0 additions & 1 deletion jscomp/core/ast_io.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US. *)

open Import
module Melange_ast_version : Ppxlib_ast.OCaml_version
module Compiler_version = Ppxlib_ast.Compiler_version

Expand Down
2 changes: 0 additions & 2 deletions jscomp/core/builtin_ast_mapper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

open Import

let rewrite_signature (ast : Parsetree.signature) : Parsetree.signature =
Ast_config.iter_on_mel_config_sigi ast;
Mel_ast_invariant.emit_external_warnings_on_signature ast;
Expand Down
2 changes: 0 additions & 2 deletions jscomp/core/builtin_ast_mapper.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

open Import

val rewrite_signature : Parsetree.signature -> Parsetree.signature
val rewrite_structure : Parsetree.structure -> Parsetree.structure
3 changes: 0 additions & 3 deletions jscomp/core/import.ml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
include Melstd
include Melange_compiler_libs

include struct
module Path = Melstd.Path
end
2 changes: 0 additions & 2 deletions jscomp/core/js_implementation.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

open Import

(** High level compilation module *)

val interface :
Expand Down
2 changes: 0 additions & 2 deletions jscomp/core/mel_ast_invariant.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,5 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

open Import

val emit_external_warnings_on_structure : Parsetree.structure -> unit
val emit_external_warnings_on_signature : Parsetree.signature -> unit
1 change: 0 additions & 1 deletion jscomp/core/meldep.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

open Import
module Set_string = Depend.String.Set

val read_parse_and_extract : 'a Ml_binary.kind -> 'a -> Set_string.t
Expand Down
2 changes: 0 additions & 2 deletions jscomp/core/ml_binary.mli
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)

open Import

type _ kind = Ml : Parsetree.structure kind | Mli : Parsetree.signature kind

val magic_of_kind : 'a kind -> string
1 change: 0 additions & 1 deletion jscomp/core/pparse_driver.mli
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
open Import

val parse_implementation : string -> Parsetree.structure
val parse_interface : string -> Parsetree.signature
5 changes: 2 additions & 3 deletions jscomp/core/record_attributes_check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,8 @@ let check_duplicated_labels =
| Some ({ txt = s; _ } as l) ->
if
String.Set.mem coll s
(*use coll to make check a bit looser
allow cases like [ x : int [@as "x"]]
*)
(* use coll to make check a bit looser
allow cases like [ x : int [@as "x"]] *)
then Some l
else
check_duplicated_labels_aux rest
Expand Down
6 changes: 3 additions & 3 deletions playground/mel_playground.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ module Melange_OCaml_version = Ast_io.Melange_ast_version

module Melange_ast = struct
external to_ppxlib :
Melange_compiler_libs.Parsetree.structure ->
Parsetree.structure ->
Melange_OCaml_version.Ast.Parsetree.structure = "%identity"

external from_ppxlib :
Melange_OCaml_version.Ast.Parsetree.structure ->
Melange_compiler_libs.Parsetree.structure = "%identity"
Parsetree.structure = "%identity"
end

let warnings_collected : Location.report list ref = ref []
Expand Down Expand Up @@ -326,7 +326,7 @@ let () =
~impl:(fun
buf : Melange_OCaml_version.Ast.Parsetree.structure ->
Melange_ast.to_ppxlib
(Melange_compiler_libs.Parse.implementation buf))
(Parse.implementation buf))
(Js.to_string code)) );
( "compileRE",
Js.wrap_meth_callback (fun _ code ->
Expand Down
4 changes: 2 additions & 2 deletions ppx/melange_ppx.ml
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ module Mapper = struct
| Some attr, Pexp_constant (Pconst_string (s, loc, Some dec)) -> (
match
Melange_ffi.Utf8_string.transform ~loc ~delim:dec
(Melange_compiler_libs.Ast_helper.Exp.constant
(Ocaml_common.Ast_helper.Exp.constant
(Pconst_string (s, loc, Some dec)))
s
with
Expand Down Expand Up @@ -827,7 +827,7 @@ module Mapper = struct
| Pexp_constant (Pconst_string (s, loc, Some dec)) -> (
match
Melange_ffi.Utf8_string.transform ~loc ~delim:dec
(Melange_compiler_libs.Ast_helper.Exp.constant
(Ocaml_common.Ast_helper.Exp.constant
(Pconst_string (s, loc, Some dec)))
s
with
Expand Down
12 changes: 1 addition & 11 deletions test/blackbox-tests/virtual-lib-compilation.t
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,7 @@
> let () = print_endline Vlib.hello
> EOF

$ dune build @mel --display=short
ocamldep vlib/.vlib.objs/virt.intf.d
ocamldep impl_melange/.impl_melange.objs/virt.impl.d
ocamldep vlib/.vlib.objs/vlib.impl.d
melc vlib/.vlib.objs/melange/virt.{cmi,cmti}
melc vlib/.vlib.objs/melange/vlib.{cmi,cmj,cmt}
melc impl_melange/.impl_melange.objs/melange/virt.{cmj,cmt}
melc output/vlib/vlib.js
melc .output.mobjs/melange/melange__X.{cmi,cmj,cmt}
melc output/impl_melange/virt.js
melc output/x.js
$ dune build @mel

$ output=_build/default/output/x.js
$ node "$output"
Expand Down
29 changes: 1 addition & 28 deletions vendor/dune
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,4 @@
(package melange)
(flags -w -9)
(libraries menhirLib melange_wrapper)
(modules_without_implementation annot outcometree parsetree))
(ocamllex
(modules lexer)
(mode fallback))
(menhir
(modules parser)
; flag reference:
; https://github.com/ocaml/ocaml/blob/f0a1be6f0/Makefile.menhir#L76-L82
(flags
--lalr
--explain
--dump
--require-aliases
--strict
--table
-lg
1
-la
1
--unused-token
COMMENT
--unused-token
DOCSTRING
--unused-token
EOL
--unused-token
GREATERRBRACKET
--fixed-exception))))
(modules_without_implementation annot))))