Skip to content

Commit 1523c1a

Browse files
committed
add ninja support for codegen
1 parent a944369 commit 1523c1a

19 files changed

+314
-175
lines changed

jscomp/bin/all_ounit_tests.ml

+40-40
Original file line numberDiff line numberDiff line change
@@ -3117,12 +3117,12 @@ end = struct
31173117
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
31183118

31193119

3120-
# 42
3120+
# 42 "ext/set.cppo.ml"
31213121
type elt = int
31223122
let compare_elt = Ext_int.compare
31233123
let print_elt = Format.pp_print_int
31243124

3125-
# 49
3125+
# 49 "ext/set.cppo.ml"
31263126
type ('a, 'id) t0 = ('a, 'id) Set_gen.t0 =
31273127
| Empty
31283128
| Node of ('a, 'id) t0 * 'a * ('a, 'id) t0 * int
@@ -6304,7 +6304,7 @@ let key_index (h : _ t ) (key : key) =
63046304
(Bs_hash_stubs.hash_string key ) land (Array.length h.data - 1)
63056305
let eq_key = Ext_string.equal
63066306

6307-
# 33
6307+
# 33 "ext/hashtbl.cppo.ml"
63086308
type ('a, 'b) bucketlist = ('a,'b) Hashtbl_gen.bucketlist
63096309
let create = Hashtbl_gen.create
63106310
let clear = Hashtbl_gen.clear
@@ -8283,12 +8283,12 @@ end = struct
82838283
* along with this program; if not, write to the Free Software
82848284
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
82858285

8286-
# 34
8286+
# 34 "ext/vec.cppo.ml"
82878287
type elt = int
82888288
let null = 0 (* can be optimized *)
82898289
let unsafe_blit = Bs_hash_stubs.int_unsafe_blit
82908290

8291-
# 41
8291+
# 41 "ext/vec.cppo.ml"
82928292
external unsafe_sub : 'a array -> int -> int -> 'a array = "caml_array_sub"
82938293

82948294
type t = {
@@ -8605,22 +8605,22 @@ let init len f =
86058605
let idx = d_len - 1 in
86068606
d.len <- idx
86078607

8608-
# 362
8608+
# 362 "ext/vec.cppo.ml"
86098609
(** pop the last element, a specialized version of [delete] *)
86108610
let pop (d : t) =
86118611
let idx = d.len - 1 in
86128612
if idx < 0 then invalid_arg "Resize_array.pop";
86138613
d.len <- idx
86148614

8615-
# 373
8615+
# 373 "ext/vec.cppo.ml"
86168616
(** pop and return the last element *)
86178617
let get_last_and_pop (d : t) =
86188618
let idx = d.len - 1 in
86198619
if idx < 0 then invalid_arg "Resize_array.get_last_and_pop";
86208620
let last = Array.unsafe_get d.arr idx in
86218621
d.len <- idx
86228622

8623-
# 384
8623+
# 384 "ext/vec.cppo.ml"
86248624
;
86258625
last
86268626

@@ -8632,7 +8632,7 @@ let init len f =
86328632
unsafe_blit arr (idx + len) arr idx (d_len - idx - len);
86338633
d.len <- d_len - len
86348634

8635-
# 402
8635+
# 402 "ext/vec.cppo.ml"
86368636
(** delete elements from [idx] with length [len] return the deleted elements as a new vec*)
86378637
let get_and_delete_range (d : t) idx len : t =
86388638
let d_len = d.len in
@@ -8642,15 +8642,15 @@ let init len f =
86428642
unsafe_blit arr (idx + len) arr idx (d_len - idx - len);
86438643
d.len <- d_len - len;
86448644

8645-
# 416
8645+
# 416 "ext/vec.cppo.ml"
86468646
{len = len ; arr = value}
86478647

86488648

86498649
(** Below are simple wrapper around normal Array operations *)
86508650

86518651
let clear (d : t ) =
86528652

8653-
# 428
8653+
# 428 "ext/vec.cppo.ml"
86548654
d.len <- 0
86558655

86568656

@@ -8671,12 +8671,12 @@ let init len f =
86718671
done ;
86728672
let last = !p in
86738673

8674-
# 448
8674+
# 448 "ext/vec.cppo.ml"
86758675
d.len <- last
86768676
(* INT , there is not need to reset it, since it will cause GC behavior *)
86778677

86788678

8679-
# 454
8679+
# 454 "ext/vec.cppo.ml"
86808680
let inplace_filter_from start f (d : t) : unit =
86818681
if start < 0 then invalid_arg "Vec.inplace_filter_from";
86828682
let d_arr = d.arr in
@@ -8694,11 +8694,11 @@ let init len f =
86948694
done ;
86958695
let last = !p in
86968696

8697-
# 471
8697+
# 471 "ext/vec.cppo.ml"
86988698
d.len <- last
86998699

87008700

8701-
# 477
8701+
# 477 "ext/vec.cppo.ml"
87028702
(** inplace filter the elements and accumulate the non-filtered elements *)
87038703
let inplace_filter_with f ~cb_no acc (d : t) =
87048704
let d_arr = d.arr in
@@ -8719,11 +8719,11 @@ let init len f =
87198719
done ;
87208720
let last = !p in
87218721

8722-
# 497
8722+
# 497 "ext/vec.cppo.ml"
87238723
d.len <- last
87248724
(* INT , there is not need to reset it, since it will cause GC behavior *)
87258725

8726-
# 502
8726+
# 502 "ext/vec.cppo.ml"
87278727
; !acc
87288728

87298729

@@ -11585,11 +11585,11 @@ end = struct
1158511585

1158611586

1158711587

11588-
# 13
11588+
# 13 "ext/map.cppo.ml"
1158911589
type key = int
1159011590
let compare_key = Ext_int.compare
1159111591

11592-
# 22
11592+
# 22 "ext/map.cppo.ml"
1159311593
type 'a t = (key,'a) Map_gen.t
1159411594
exception Duplicate_key of key
1159511595

@@ -12605,7 +12605,7 @@ end = struct
1260512605
* You should have received a copy of the GNU Lesser General Public License
1260612606
* along with this program; if not, write to the Free Software
1260712607
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *)
12608-
# 25
12608+
# 25 "ext/vec.cppo.ml"
1260912609
external unsafe_blit :
1261012610
'a array -> int -> 'a array -> int -> int -> unit = "caml_array_blit"
1261112611
module Make ( Resize : Vec_gen.ResizeType) = struct
@@ -12614,7 +12614,7 @@ module Make ( Resize : Vec_gen.ResizeType) = struct
1261412614
let null = Resize.null
1261512615

1261612616

12617-
# 41
12617+
# 41 "ext/vec.cppo.ml"
1261812618
external unsafe_sub : 'a array -> int -> int -> 'a array = "caml_array_sub"
1261912619

1262012620
type t = {
@@ -12931,34 +12931,34 @@ let init len f =
1293112931
let idx = d_len - 1 in
1293212932
d.len <- idx
1293312933

12934-
# 358
12934+
# 358 "ext/vec.cppo.ml"
1293512935
;
1293612936
Array.unsafe_set arr idx null
1293712937

12938-
# 362
12938+
# 362 "ext/vec.cppo.ml"
1293912939
(** pop the last element, a specialized version of [delete] *)
1294012940
let pop (d : t) =
1294112941
let idx = d.len - 1 in
1294212942
if idx < 0 then invalid_arg "Resize_array.pop";
1294312943
d.len <- idx
1294412944

12945-
# 369
12945+
# 369 "ext/vec.cppo.ml"
1294612946
;
1294712947
Array.unsafe_set d.arr idx null
1294812948

12949-
# 373
12949+
# 373 "ext/vec.cppo.ml"
1295012950
(** pop and return the last element *)
1295112951
let get_last_and_pop (d : t) =
1295212952
let idx = d.len - 1 in
1295312953
if idx < 0 then invalid_arg "Resize_array.get_last_and_pop";
1295412954
let last = Array.unsafe_get d.arr idx in
1295512955
d.len <- idx
1295612956

12957-
# 381
12957+
# 381 "ext/vec.cppo.ml"
1295812958
;
1295912959
Array.unsafe_set d.arr idx null
1296012960

12961-
# 384
12961+
# 384 "ext/vec.cppo.ml"
1296212962
;
1296312963
last
1296412964

@@ -12970,13 +12970,13 @@ let init len f =
1297012970
unsafe_blit arr (idx + len) arr idx (d_len - idx - len);
1297112971
d.len <- d_len - len
1297212972

12973-
# 396
12973+
# 396 "ext/vec.cppo.ml"
1297412974
;
1297512975
for i = d_len - len to d_len - 1 do
1297612976
Array.unsafe_set arr i null
1297712977
done
1297812978

12979-
# 402
12979+
# 402 "ext/vec.cppo.ml"
1298012980
(** delete elements from [idx] with length [len] return the deleted elements as a new vec*)
1298112981
let get_and_delete_range (d : t) idx len : t =
1298212982
let d_len = d.len in
@@ -12986,25 +12986,25 @@ let init len f =
1298612986
unsafe_blit arr (idx + len) arr idx (d_len - idx - len);
1298712987
d.len <- d_len - len;
1298812988

12989-
# 412
12989+
# 412 "ext/vec.cppo.ml"
1299012990
for i = d_len - len to d_len - 1 do
1299112991
Array.unsafe_set arr i null
1299212992
done;
1299312993

12994-
# 416
12994+
# 416 "ext/vec.cppo.ml"
1299512995
{len = len ; arr = value}
1299612996

1299712997

1299812998
(** Below are simple wrapper around normal Array operations *)
1299912999

1300013000
let clear (d : t ) =
1300113001

13002-
# 424
13002+
# 424 "ext/vec.cppo.ml"
1300313003
for i = 0 to d.len - 1 do
1300413004
Array.unsafe_set d.arr i null
1300513005
done;
1300613006

13007-
# 428
13007+
# 428 "ext/vec.cppo.ml"
1300813008
d.len <- 0
1300913009

1301013010

@@ -13025,11 +13025,11 @@ let init len f =
1302513025
done ;
1302613026
let last = !p in
1302713027

13028-
# 451
13028+
# 451 "ext/vec.cppo.ml"
1302913029
delete_range d last (d_len - last)
1303013030

1303113031

13032-
# 454
13032+
# 454 "ext/vec.cppo.ml"
1303313033
let inplace_filter_from start f (d : t) : unit =
1303413034
if start < 0 then invalid_arg "Vec.inplace_filter_from";
1303513035
let d_arr = d.arr in
@@ -13047,11 +13047,11 @@ let init len f =
1304713047
done ;
1304813048
let last = !p in
1304913049

13050-
# 473
13050+
# 473 "ext/vec.cppo.ml"
1305113051
delete_range d last (d_len - last)
1305213052

1305313053

13054-
# 477
13054+
# 477 "ext/vec.cppo.ml"
1305513055
(** inplace filter the elements and accumulate the non-filtered elements *)
1305613056
let inplace_filter_with f ~cb_no acc (d : t) =
1305713057
let d_arr = d.arr in
@@ -13072,15 +13072,15 @@ let init len f =
1307213072
done ;
1307313073
let last = !p in
1307413074

13075-
# 500
13075+
# 500 "ext/vec.cppo.ml"
1307613076
delete_range d last (d_len - last)
1307713077

13078-
# 502
13078+
# 502 "ext/vec.cppo.ml"
1307913079
; !acc
1308013080

1308113081

1308213082

13083-
# 507
13083+
# 507 "ext/vec.cppo.ml"
1308413084
end
1308513085

1308613086
end

jscomp/bin/bspack.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -8299,7 +8299,7 @@ let key_index (h : _ t ) (key : key) =
82998299
(Bs_hash_stubs.hash_string key ) land (Array.length h.data - 1)
83008300
let eq_key = Ext_string.equal
83018301

8302-
# 33
8302+
# 33 "ext/hashtbl.cppo.ml"
83038303
type ('a, 'b) bucketlist = ('a,'b) Hashtbl_gen.bucketlist
83048304
let create = Hashtbl_gen.create
83058305
let clear = Hashtbl_gen.clear

jscomp/compiler.ninja

+41
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,47 @@ rule bspack
4949
generator = true
5050
build ./bin/tests.exe: link ounit/ounit.cmxa stubs/stubs.cmxa ext/ext.cmxa common/common.cmxa syntax/syntax.cmxa depends/depends.cmxa bsb/bsb.cmxa core/core.cmxa ounit_tests/ounit_tests.cmxa main/ounit_tests_main.cmx
5151
libs = str.cmxa unix.cmxa ocamlcommon.cmxa
52+
rule cppo
53+
command = cppo -D $type $in -o $out
54+
generator = true
55+
build ext/string_hash_set.ml : cppo ext/hash_set.cppo.ml
56+
type = TYPE_STRING
57+
build ext/int_hash_set.ml : cppo ext/hash_set.cppo.ml
58+
type = TYPE_INT
59+
build ext/ident_hash_set.ml : cppo ext/hash_set.cppo.ml
60+
type = TYPE_IDENT
61+
build ext/hash_set.ml : cppo ext/hash_set.cppo.ml
62+
type = TYPE_FUNCTOR
63+
build ext/hash_set_poly.ml : cppo ext/hash_set.cppo.ml
64+
type = TYPE_POLY
65+
build ext/int_vec.ml : cppo ext/vec.cppo.ml
66+
type = TYPE_INT
67+
build ext/resize_array.ml : cppo ext/vec.cppo.ml
68+
type = TYPE_FUNCTOR
69+
build ext/string_set.ml : cppo ext/set.cppo.ml
70+
type = TYPE_STRING
71+
build ext/set_int.ml : cppo ext/set.cppo.ml
72+
type = TYPE_INT
73+
build ext/ident_set.ml : cppo ext/set.cppo.ml
74+
type = TYPE_IDENT
75+
build ext/string_map.ml : cppo ext/map.cppo.ml
76+
type = TYPE_STRING
77+
build ext/int_map.ml : cppo ext/map.cppo.ml
78+
type = TYPE_INT
79+
build ext/ident_map.ml : cppo ext/map.cppo.ml
80+
type = TYPE_IDENT
81+
build ext/ordered_hash_map_local_ident.ml : cppo ext/ordered_hash_map.cppo.ml
82+
type = TYPE_LOCAL_IDENT
83+
build ext/ordered_hash_set_make.ml : cppo ext/ordered_hash_set.cppo.ml
84+
type = TYPE_FUNCTOR
85+
build ext/string_hashtbl.ml : cppo ext/hashtbl.cppo.ml
86+
type = TYPE_STRING
87+
build ext/int_hashtbl.ml : cppo ext/hashtbl.cppo.ml
88+
type = TYPE_INT
89+
build ext/ident_hashtbl.ml : cppo ext/hashtbl.cppo.ml
90+
type = TYPE_IDENT
91+
build ext/hashtbl_make.ml : cppo ext/hashtbl.cppo.ml
92+
type = TYPE_FUNCTOR
5293
build stubs/bs_hash_stubs.cmx stubs/bs_hash_stubs.cmi : optc stubs/bs_hash_stubs.ml |
5394
build ext/ext_array.cmx : optc ext/ext_array.ml | ext/ext_array.cmi
5495
build ext/ext_array.cmi : optc ext/ext_array.mli |

jscomp/ext/hashtbl_make.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Make (Key : Hashtbl.HashedType) = struct
77
let eq_key = Key.equal
88

99

10-
# 33
10+
# 33 "ext/hashtbl.cppo.ml"
1111
type ('a, 'b) bucketlist = ('a,'b) Hashtbl_gen.bucketlist
1212
let create = Hashtbl_gen.create
1313
let clear = Hashtbl_gen.clear
@@ -135,5 +135,5 @@ let of_list2 ks vs =
135135
List.iter2 (fun k v -> add map k v) ks vs ;
136136
map
137137

138-
# 161
138+
# 161 "ext/hashtbl.cppo.ml"
139139
end

jscomp/ext/ident_hashtbl.ml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ let key_index (h : _ t ) (key : key) =
66
(* (Bs_hash_stubs.hash_string_int key.name key.stamp ) land (Array.length h.data - 1) *)
77
let eq_key = Ext_ident.equal
88

9-
# 33
9+
# 33 "ext/hashtbl.cppo.ml"
1010
type ('a, 'b) bucketlist = ('a,'b) Hashtbl_gen.bucketlist
1111
let create = Hashtbl_gen.create
1212
let clear = Hashtbl_gen.clear

jscomp/ext/ident_map.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44

55

66

7-
# 16
7+
# 16 "ext/map.cppo.ml"
88
type key = Ident.t
99
let compare_key = Ext_ident.compare
1010

11-
# 22
11+
# 22 "ext/map.cppo.ml"
1212
type 'a t = (key,'a) Map_gen.t
1313
exception Duplicate_key of key
1414

0 commit comments

Comments
 (0)