Skip to content

Commit d5a0ece

Browse files
committed
ready for json
1 parent 05b22a0 commit d5a0ece

6 files changed

+24
-19
lines changed

jscomp/core/lam_compile_const.ml

+9
Original file line numberDiff line numberDiff line change
@@ -91,3 +91,12 @@ let rec translate (x : Lam.constant ) : J.expression =
9191

9292
| Const_immstring s -> (*TODO *)
9393
E.str s (* TODO: check *)
94+
95+
96+
let translate_arg_cst (cst : Ast_arg.cst) =
97+
(match cst with
98+
| Arg_int_lit i ->
99+
E.int (Int32.of_int i)
100+
| Arg_string_lit i ->
101+
E.str i
102+
| Arg_js_null -> assert false)

jscomp/core/lam_compile_const.mli

+3
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@
3232
(** Compile lambda constant to JS *)
3333

3434
val translate : Lam.constant -> J.expression
35+
36+
37+
val translate_arg_cst : Ast_arg.cst -> J.expression

jscomp/core/lam_compile_external_call.ml

+4-9
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,10 @@ let assemble_args_splice call_loc ffi js_splice arg_types args : E.t list * E.t
133133
let rec aux (labels : Ast_arg.kind list) args =
134134
match labels, args with
135135
| [] , [] -> empty_pair
136-
| { arg_label = Empty (Some (Arg_int_lit i)) } :: labels , args
137-
| { arg_label = Label (_, Some (Arg_int_lit i))} :: labels , args ->
138-
let accs, eff = aux labels args in
139-
E.int (Int32.of_int i) ::accs, eff
140-
| { arg_label = Label (_, Some (Arg_string_lit i))} :: labels , args
141-
| { arg_label = Empty (Some (Arg_string_lit i)) } :: labels , args
142-
->
143-
let accs, eff = aux labels args in
144-
E.str i :: accs, eff
136+
| { arg_label = Empty (Some cst) } :: labels , args
137+
| { arg_label = Label (_, Some cst)} :: labels , args ->
138+
let accs, eff = aux labels args in
139+
Lam_compile_const.translate_arg_cst cst :: accs, eff
145140
| ({arg_label = Empty None | Label (_,None) | Optional _ } as arg_kind) ::labels, arg :: args
146141
->
147142
if js_splice && args = [] then

jscomp/core/lam_compile_external_obj.ml

+3-8
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,10 @@ let assemble_args_obj (labels : Ast_arg.kind list) (args : J.expression list) =
4343
let rec aux (labels : Ast_arg.kind list) args =
4444
match labels, args with
4545
| [] , [] as empty_pair -> empty_pair
46-
| {arg_label = Label (label, Some (Arg_int_lit i))} :: labels , args ->
46+
| {arg_label = Label (label, Some cst )} :: labels , args ->
4747
let accs, eff = aux labels args in
48-
(Js_op.Key label, E.int (Int32.of_int i) )::accs, eff
49-
| {arg_label = Label(label, Some (Arg_string_lit i))} :: labels , args
50-
->
51-
let accs, eff = aux labels args in
52-
(Js_op.Key label, E.str i) :: accs, eff
53-
| {arg_label = Empty (Some (Arg_int_lit i)) } :: rest , args -> assert false
54-
| {arg_label = Empty(Some (Arg_string_lit i))} :: rest , args -> assert false
48+
(Js_op.Key label, Lam_compile_const.translate_arg_cst cst )::accs, eff
49+
| {arg_label = Empty (Some _) } :: rest , args -> assert false
5550
| {arg_label = Empty None }::labels, arg::args
5651
->
5752
let (accs, eff) as r = aux labels args in

jscomp/syntax/ast_arg.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ type cst =
2828
| Arg_int_lit of int
2929
| Arg_string_lit of string
3030

31-
31+
| Arg_js_null
3232
type label =
3333
| Label of string * cst option
3434
| Empty of cst option

jscomp/syntax/ast_arg.mli

+4-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525
type cst =
2626
| Arg_int_lit of int
2727
| Arg_string_lit of string
28-
28+
(* | Arg_js_true *)
29+
(* | Arg_js_false *)
30+
| Arg_js_null
31+
2932

3033
type label = private
3134
| Label of string * cst option

0 commit comments

Comments
 (0)