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
6 changes: 6 additions & 0 deletions jscomp/j_helper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,12 @@ module Exp = struct

let float_minus ?comment (e0 : t) (e1 : t) : t =
{comment ; expression_desc = Bin (Minus,e0,e1)}


let float_mod ?comment e1 e2 : J.expression =
{ comment ;
expression_desc = Bin (Mod, e1,e2)
}

let obj ?comment properties : t =
{expression_desc = Object properties; comment }
Expand Down
2 changes: 1 addition & 1 deletion jscomp/j_helper.mli
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ module Exp : sig
val float_minus : binary_op
val float_notequal : binary_op


val float_mod : binary_op
val not : t -> t

val call : ?comment:string -> ?info:Js_call_info.t -> t -> t list -> t
Expand Down
17 changes: 14 additions & 3 deletions jscomp/lam_dispatch_primitive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,17 @@ let query (prim : Lam_compile_env.primitive_description)
| "caml_copysign_float"
| "caml_expm1_float"
| "caml_hypot_float"
(* "caml_fmod_float"; TODO: *)

->
E.runtime_call J_helper.float prim.prim_name args
| "caml_fmod_float"
(* float module like js number module *)
->
begin match args with
| [e0;e1] -> E.float_mod e0 e1
| _ -> assert false
end

| "caml_string_equal"
->
begin match args with
Expand Down Expand Up @@ -655,8 +663,11 @@ let query (prim : Lam_compile_env.primitive_description)
| _ -> assert false
end
| _ ->
E.str ~comment:"Missing primitve" ~pure:false prim.prim_name;
(* raise X.NA *) (* Fall back, maybe spit out a warning*)

let comment = "Missing primitve" in
Ext_log.warn __LOC__ "%s" (Printf.sprintf "%s: %s\n" comment prim.prim_name) ;
E.str ~comment ~pure:false prim.prim_name;
(* raise X.NA *) (* Fall back, maybe spit out a warning*)
end in
v
with X.NA ->
Expand Down
4 changes: 4 additions & 0 deletions jscomp/test/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ obj_test.cmo : mt.cmo
obj_test.cmx : mt.cmx
of_string_test.cmo : mt.cmo
of_string_test.cmx : mt.cmx
primitive_reg_test.cmo :
primitive_reg_test.cmx :
qcc.cmo : ../stdlib/sys.cmi ../stdlib/string.cmi ../stdlib/printf.cmi \
../stdlib/list.cmi ../stdlib/char.cmi ../stdlib/bytes.cmi \
../stdlib/array.cmi
Expand Down Expand Up @@ -461,6 +463,8 @@ obj_test.cmo : mt.cmo
obj_test.cmo : mt.cmo
of_string_test.cmo : mt.cmo
of_string_test.cmo : mt.cmo
primitive_reg_test.cmo :
primitive_reg_test.cmo :
qcc.cmo : ../stdlib/sys.cmi ../stdlib/string.cmi ../stdlib/printf.cmi \
../stdlib/list.cmi ../stdlib/char.cmi ../stdlib/bytes.cmi \
../stdlib/array.cmi
Expand Down
2 changes: 2 additions & 0 deletions jscomp/test/primitive_reg_test.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export var x: (prim : any, prim : any) => any ;

10 changes: 10 additions & 0 deletions jscomp/test/primitive_reg_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Generated CODE, PLEASE EDIT WITH CARE
"use strict";


function x(prim, prim$1) {
return prim % prim$1;
}

exports.x = x;
/* No side effect */
1 change: 1 addition & 0 deletions jscomp/test/primitive_reg_test.ml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
let x = mod_float
3 changes: 2 additions & 1 deletion jscomp/test/test.mllib
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,5 @@ obj_test
demo_page
complex_test
inline_edge_cases
inline_regression_test
inline_regression_test
primitive_reg_test
2 changes: 1 addition & 1 deletion jscomp/test/test_react.ml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class type doc =
object
method getElementById : string -> html_element
end
external doc : doc = "doc" [@@js.global]
external doc : doc = "doc" [@@js.global "doc"]

class type console =
object
Expand Down