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
2 changes: 1 addition & 1 deletion jscomp/common/bs_loc.ml
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,4 @@ let merge (l: t) (r : t) =
->
{loc_start ;loc_end; loc_ghost = false}

let none = Location.none
(* let none = Location.none *)
4 changes: 2 additions & 2 deletions jscomp/common/bs_loc.mli
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type t = Location.t = {
loc_ghost : bool
}

val is_ghost : t -> bool
(* val is_ghost : t -> bool *)
val merge : t -> t -> t
val none : t
(* val none : t *)

2 changes: 1 addition & 1 deletion jscomp/common/js_config.ml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ let set_cross_module_inline b =

let diagnose = ref false
let get_diagnose () = !diagnose
let set_diagnose b = diagnose := b
(* let set_diagnose b = diagnose := b *)

(* let (//) = Filename.concat *)

Expand Down
2 changes: 1 addition & 1 deletion jscomp/common/js_config.mli
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ val get_cross_module_inline : unit -> bool
(** diagnose option *)
val diagnose : bool ref
val get_diagnose : unit -> bool
val set_diagnose : bool -> unit
(* val set_diagnose : bool -> unit *)


(** options for builtin ppx *)
Expand Down
4 changes: 2 additions & 2 deletions jscomp/core/js_analyzer.ml
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ let rev_toplevel_flatten block =
| x :: xs -> aux (x :: acc) xs in
aux [] block

let rec is_constant (x : J.expression) =
(* let rec is_constant (x : J.expression) =
match x.expression_desc with
| Array_index (a,b) -> is_constant a && is_constant b
| Str (b,_) -> b
Expand All @@ -360,7 +360,7 @@ let rec is_constant (x : J.expression) =
-> Ext_list.for_all xs is_constant && is_constant tag
| Bin (_op, a, b) ->
is_constant a && is_constant b
| _ -> false
| _ -> false *)


let rec is_okay_to_duplicate (e : J.expression) =
Expand Down
7 changes: 4 additions & 3 deletions jscomp/core/js_analyzer.mli
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ val free_variables_of_statement :
val free_variables_of_expression :
Set_ident.t -> Set_ident.t -> J.finish_ident_expression -> Set_ident.t

val no_side_effect_expression_desc :
J.expression_desc -> bool
(* val no_side_effect_expression_desc :
J.expression_desc -> bool *)

val no_side_effect_expression :
J.expression -> bool
(** [no_side_effect] means this expression has no side effect,
Expand Down Expand Up @@ -77,7 +78,7 @@ val rev_flatten_seq : J.expression -> J.block
val rev_toplevel_flatten : J.block -> J.block
(** return the block in reverse order *)

val is_constant : J.expression -> bool
(* val is_constant : J.expression -> bool *)


(** Simple expression,
Expand Down
8 changes: 4 additions & 4 deletions jscomp/core/js_exp_make.ml
Original file line number Diff line number Diff line change
Expand Up @@ -326,8 +326,8 @@ let fuse_to_seq x xs =
if xs = [] then x
else Ext_list.fold_left xs x seq

let empty_string_literal : t =
{expression_desc = Str (true,""); comment = None}
(* let empty_string_literal : t =
{expression_desc = Str (true,""); comment = None} *)

let zero_int_literal : t =
{expression_desc = Number (Int {i = 0l; c = None}) ; comment = None}
Expand Down Expand Up @@ -506,15 +506,15 @@ let function_length ?comment (e : t) : t =
| _ -> { expression_desc = Length (e, Function) ; comment }

(** no dependency introduced *)
let js_global_dot ?comment (x : string) (e1 : string) : t =
(* let js_global_dot ?comment (x : string) (e1 : string) : t =
{ expression_desc = Static_index (js_global x, e1,None); comment}

let char_of_int ?comment (v : t) : t =
match v.expression_desc with
| Number (Int {i; _}) ->
str (String.make 1(Char.chr (Int32.to_int i)))
| Char_to_int v -> v
| _ -> {comment ; expression_desc = Char_of_int v}
| _ -> {comment ; expression_desc = Char_of_int v} *)

let char_to_int ?comment (v : t) : t =
match v.expression_desc with
Expand Down
10 changes: 5 additions & 5 deletions jscomp/core/js_exp_make.mli
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ val nint : ?comment:string -> nativeint -> t
val small_int : int -> t
val float : ?comment:string -> string -> t

val empty_string_literal : t
(* val empty_string_literal : t *)
(* TODO: we can do hash consing for small integers *)
val zero_int_literal : t
val one_int_literal : t
(* val one_int_literal : t *)
val zero_float_lit : t
val obj_int_tag_literal : t
(* val obj_int_tag_literal : t *)

(** [is_out e range] is equivalent to [e > range or e <0]

Expand All @@ -147,7 +147,7 @@ val bytes_length : ?comment:string -> t -> t

val function_length : ?comment:string -> t -> t

val char_of_int : ?comment:string -> t -> t
(* val char_of_int : ?comment:string -> t -> t *)

val char_to_int : ?comment:string -> t -> t

Expand All @@ -164,7 +164,7 @@ val string_append : ?comment:string -> t -> t -> t
(* val bind_var_call : ?comment:string -> Ident.t -> string -> t list -> t *)

(* val bind_call : ?comment:string -> J.expression -> string -> J.expression list -> t *)
val js_global_dot : ?comment:string -> string -> string -> t
(* val js_global_dot : ?comment:string -> string -> string -> t *)



Expand Down
8 changes: 4 additions & 4 deletions jscomp/core/js_fold_basic.ml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@



class count_deps (add : Ident.t -> unit ) =
(* class count_deps (add : Ident.t -> unit ) =
object(self)
inherit Js_fold.fold as super
method! expression lam =
Expand All @@ -46,7 +46,7 @@ class count_deps (add : Ident.t -> unit ) =
*)
| _ -> super#expression lam
method! ident x = add x ; self
end
end *)

let add_lam_module_ident = Lam_module_ident.Hash_set.add
let create = Lam_module_ident.Hash_set.create
Expand Down Expand Up @@ -82,12 +82,12 @@ let calculate_hard_dependencies block =
will not depend [variables]

*)
let depends_j (lam : J.expression) (variables : Set_ident.t) =
(* let depends_j (lam : J.expression) (variables : Set_ident.t) =
let v = ref Set_ident.empty in
let add id =
if Set_ident.mem variables id then
v := Set_ident.add !v id
in
ignore @@ (new count_deps add ) # expression lam ;
!v

*)
2 changes: 1 addition & 1 deletion jscomp/core/js_fold_basic.mli
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

(** A module to calculate hard dependency based on JS IR in module [J] *)

val depends_j : J.expression -> Set_ident.t -> Set_ident.t
(* val depends_j : J.expression -> Set_ident.t -> Set_ident.t *)

(** TODO: {!Ordered_hash_set} for better ordering *)
val calculate_hard_dependencies : J.block -> Lam_module_ident.Hash_set.t
12 changes: 6 additions & 6 deletions jscomp/core/js_fun_env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -68,22 +68,22 @@ let make ?immutable_mask n = {
bound_loop_mutable_values =Set_ident.empty;
}

let is_tailcalled x =
x.immutable_mask <> All_immutable_and_no_tail_call
(* let is_tailcalled x =
x.immutable_mask <> All_immutable_and_no_tail_call *)

let mark_unused t i =
t.used_mask.(i) <- true

let get_unused t i =
t.used_mask.(i)

let get_length t = Array.length t.used_mask
(* let get_length t = Array.length t.used_mask *)

let to_string env =
(* let to_string env =
String.concat ","
(Ext_list.map (Set_ident.elements env.unbounded )
(fun id -> Printf.sprintf "%s/%d" id.name id.stamp)
)
) *)

let get_mutable_params (params : Ident.t list) (x : t ) =
match x.immutable_mask with
Expand All @@ -110,4 +110,4 @@ let get_lexical_scope env =
(* TODO: can be refined if it
only enclose toplevel variables
*)
let is_empty t = Set_ident.is_empty t.unbounded
(* let is_empty t = Set_ident.is_empty t.unbounded *)
8 changes: 4 additions & 4 deletions jscomp/core/js_fun_env.mli
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ type t

val make : ?immutable_mask:bool array -> int -> t

val is_tailcalled : t -> bool
(* val is_tailcalled : t -> bool

val is_empty : t -> bool
val is_empty : t -> bool *)

val set_unbounded : t -> Set_ident.t -> unit

Expand All @@ -49,7 +49,7 @@ val set_lexical_scope : t -> Set_ident.t -> unit

val get_lexical_scope : t -> Set_ident.t

val to_string : t -> string
(* val to_string : t -> string *)

val mark_unused : t -> int -> unit

Expand All @@ -59,4 +59,4 @@ val get_mutable_params : Ident.t list -> t -> Ident.t list

val get_unbounded : t -> Set_ident.t

val get_length : t -> int
(* val get_length : t -> int *)
4 changes: 2 additions & 2 deletions jscomp/core/js_implementation.mli
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ val interface_mliast : Format.formatter -> string -> string -> unit



val after_parsing_impl :
(* val after_parsing_impl :
Format.formatter ->
string ->
Parsetree.structure ->
unit
unit *)
(** [after_parsing_impl ppf sourcefile outputprefix ast ]
Make sure you need run {!Compmisc.init_path} for set up
Used in eval
Expand Down
16 changes: 8 additions & 8 deletions jscomp/core/js_stmt_make.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ type t = J.statement
let return_stmt ?comment e : t =
{statement_desc = Return {return_value = e; } ; comment}

let return_unit : t list =
(* let return_unit : t list =
[{ statement_desc = Return {return_value = E.unit; } ;
comment = None}]
comment = None}] *)

let empty_stmt : t =
{ statement_desc = Block []; comment = None}
Expand Down Expand Up @@ -86,12 +86,12 @@ let define_variable ?comment ?ident_info
ident_info ;};
comment}

let alias_variable ?comment ~exp (v:Ident.t) : t=
(* let alias_variable ?comment ~exp (v:Ident.t) : t=
{statement_desc =
Variable {
ident = v; value = Some exp; property = Alias;
ident_info = {used_stats = NA } };
comment}
comment} *)


let int_switch
Expand Down Expand Up @@ -301,7 +301,7 @@ let assign ?comment id e : t =
statement_desc = J.Exp ( E.assign (E.var id) e ) ;
comment
}
let assign_unit ?comment id : t =
(* let assign_unit ?comment id : t =
{
statement_desc = J.Exp( E.assign (E.var id) E.unit);
comment
Expand All @@ -315,7 +315,7 @@ let declare_unit ?comment id : t =
ident_info = {used_stats = NA}
};
comment
}
} *)

let while_ ?comment ?label ?env (e : E.t) (st : J.block) : t =
let env =
Expand Down Expand Up @@ -350,11 +350,11 @@ let try_ ?comment ?with_ ?finally body : t =
(* TODO:
actually, only loops can be labelled
*)
let continue_stmt ?comment ?(label="") () : t =
(* let continue_stmt ?comment ?(label="") () : t =
{
statement_desc = J.Continue label;
comment;
}
} *)

let continue_ : t = {
statement_desc = Continue "" ;
Expand Down
23 changes: 12 additions & 11 deletions jscomp/core/js_stmt_make.mli
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ type t = J.statement


(** empty statement, block of length 0 *)
val empty_stmt :
t
(* val empty_stmt :
t *)

val throw_stmt :
?comment:string ->
Expand Down Expand Up @@ -113,11 +113,11 @@ val define_variable :
t

(** created an alias expression *)
val alias_variable :
(* val alias_variable :
?comment:string ->
exp:J.expression ->
Ident.t ->
t
t *)

val assign :
?comment:string ->
Expand All @@ -132,10 +132,10 @@ val assign :
done in ..
]}
*)
val assign_unit :
(* val assign_unit :
?comment:string ->
J.ident ->
t
t *)

(** used in cases like
{[
Expand All @@ -144,10 +144,10 @@ val assign_unit :
done in ..
]}
*)
val declare_unit :
(* val declare_unit :
?comment:string ->
J.ident ->
t
t *)

val while_ :
?comment:string ->
Expand Down Expand Up @@ -185,16 +185,17 @@ val return_stmt :
t


val return_unit : t list
(* val return_unit : t list *)
(** for ocaml function which returns unit
it will be compiled into [return 0] in js *)

(** if [label] is not set, it will default to empty *)
val continue_stmt :
(* val continue_stmt :
?comment:string ->
?label:J.label ->
unit ->
t
t *)

val continue_ : t

val debugger_block : t list
2 changes: 1 addition & 1 deletion jscomp/core/lam_bounded_vars.ml
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,4 @@ let rewrite (map : _ Hash_ident.t)
aux lam


let refresh lam = rewrite (Hash_ident.create 17 : Lam.t Hash_ident.t ) lam
(* let refresh lam = rewrite (Hash_ident.create 17 : Lam.t Hash_ident.t ) lam *)
4 changes: 2 additions & 2 deletions jscomp/core/lam_bounded_vars.mli
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
val rewrite : Lam.t Hash_ident.t -> Lam.t -> Lam.t

(** refresh lambda to replace all bounded vars for new ones *)
val refresh :
(* val refresh :
Lam.t ->
Lam.t
Lam.t *)
Loading