Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cyclic dependencies core <-> frontend #5915

Merged
merged 1 commit into from
Dec 26, 2022
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: 1 addition & 3 deletions jscomp/core/dune
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
(run %{bin:cppo} %{env:CPPO_FLAGS=} %{input-file})))
(flags
(:standard -w +a-4-9-27-30-40-41-42-48-70))
(libraries depends gentype js_parser outcome_printer))
(libraries depends frontend gentype js_parser outcome_printer))

; There exist cyclic dependencies between core and frontend, therefore include frontend files here:

(copy_files# ../frontend/*.{ml,mli})

(copy_files# ../cmij/cmij_cache.{ml,mli})
2 changes: 1 addition & 1 deletion jscomp/core/j.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ and for_ident = ident
and for_direction = Js_op.direction_flag
and property_map = (property_name * expression) list
and length_object = Js_op.length_object
and delim = | DNone | DStarJ | DJson
and delim = External_arg_spec.delim = | DNone | DStarJ | DJson

and expression_desc =
| Length of expression * length_object
Expand Down
2 changes: 1 addition & 1 deletion jscomp/frontend/ast_attributes.ml
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ let iter_process_bs_int_as (attrs : t) =
| _ -> ());
!st

type as_const_payload = Int of int | Str of string * J.delim
type as_const_payload = Int of int | Str of string * External_arg_spec.delim

let iter_process_bs_string_or_int_as (attrs : Parsetree.attributes) =
let st = ref None in
Expand Down
2 changes: 1 addition & 1 deletion jscomp/frontend/ast_attributes.mli
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ val has_bs_optional : t -> bool

val iter_process_bs_int_as : t -> int option

type as_const_payload = Int of int | Str of string * J.delim
type as_const_payload = Int of int | Str of string * External_arg_spec.delim
val iter_process_bs_string_or_int_as : t -> as_const_payload option

val process_derive_type : t -> derive_attr * t
Expand Down
2 changes: 1 addition & 1 deletion jscomp/frontend/ast_utf8_string_interp.ml
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ let to_string_ident : Longident.t = Ldot (Ldot (Lident "Js", "String2"), "make")

module Delim = struct
let parse_processed = function
| None -> Some J.DNone
| None -> Some External_arg_spec.DNone
| Some "json" -> Some DJson
| Some "*j" -> Some DStarJ
| _ -> None
Expand Down
2 changes: 1 addition & 1 deletion jscomp/frontend/ast_utf8_string_interp.mli
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ val transform_test : string -> segment list
val transform : Parsetree.expression -> string -> string -> Parsetree.expression
val is_unicode_string : string -> bool
val is_unescaped : string -> bool
val parse_processed_delim : string option -> J.delim option
val parse_processed_delim : string option -> External_arg_spec.delim option
9 changes: 9 additions & 0 deletions jscomp/frontend/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(library
(name frontend)
(wrapped false)
(preprocess
(action
(run %{bin:cppo} %{env:CPPO_FLAGS=} %{input-file})))
(flags
(:standard -w +a-4-9-40-42-70))
(libraries common js_parser ml))
4 changes: 3 additions & 1 deletion jscomp/frontend/external_arg_spec.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@

(** type definitions for arguments to a function declared external *)

type delim = | DNone | DStarJ | DJson

type cst =
| Arg_int_lit of int
| Arg_string_lit of string * J.delim
| Arg_string_lit of string * delim

type label_noname = Arg_label | Arg_empty | Arg_optional

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

type delim = | DNone | DStarJ | DJson

type cst = private
| Arg_int_lit of int
| Arg_string_lit of string * J.delim
| Arg_string_lit of string * delim

type attr =
| Poly_var_string of { descr : (string * string) list }
Expand Down Expand Up @@ -56,7 +58,7 @@ type params = param list

val cst_int : int -> cst

val cst_string : string -> J.delim -> cst
val cst_string : string -> delim -> cst

val empty_label : label

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type t =
| Const_float of string
| Const_int64 of int64
| Const_pointer of string
| Const_block of int * Lam_tag_info.t * t list
| Const_block of int * Lambda.tag_info * t list
| Const_float_array of string list
| Const_some of t
| Const_module_alias
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type t =
| Const_float of string
| Const_int64 of int64
| Const_pointer of string
| Const_block of int * Lam_tag_info.t * t list
| Const_block of int * Lambda.tag_info * t list
| Const_float_array of string list
| Const_some of t
(* eventually we can remove it, since we know
Expand Down