Skip to content

Commit

Permalink
Merge 3613d21 into 7d5f42c
Browse files Browse the repository at this point in the history
  • Loading branch information
bobzhang committed Jan 16, 2018
2 parents 7d5f42c + 3613d21 commit ad93c75
Show file tree
Hide file tree
Showing 97 changed files with 6,183 additions and 2,176 deletions.
2 changes: 1 addition & 1 deletion jscomp/core/lam_pass_eliminate_ref.ml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let rec eliminate_ref id (lam : Lam.t) =
| Lprim {primitive = Pfield (0,_); args = [Lvar v]} when Ident.same v id ->
Lam.var id
| Lfunction{ function_kind; params; body} as lam ->
if Ident_set.mem id (Lam.free_variables lam)
if Ident_set.mem id (Lam.free_variables lam) (*TODO: optmization: no need construct*)
then raise_notrace Real_reference
else lam
(* In Javascript backend, its okay, we can reify it later
Expand Down
33 changes: 24 additions & 9 deletions jscomp/others/.depend
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ js_console.cmj :
js_result.cmj : js_result.cmi
js_mapperRt.cmj : js_mapperRt.cmi
bs_Array.cmj : js_math.cmj bs_Array.cmi
bs_internalAVLset.cmj : bs_Cmp.cmj bs_Array.cmj bs_internalAVLset.cmi
bs_internalAVLtree.cmj : bs_Array.cmj bs_internalAVLtree.cmi
bs_internalAVLset.cmj : bs_Sort.cmj bs_Cmp.cmj bs_Array.cmj \
bs_internalAVLset.cmi
bs_internalAVLtree.cmj : bs_Sort.cmj bs_Cmp.cmj bs_Array.cmj \
bs_internalAVLtree.cmi
bs_SetIntM.cmj : bs_internalSetInt.cmj bs_internalAVLset.cmj bs_SortInt.cmj \
bs_Array.cmj bs_SetIntM.cmi
bs_Hash.cmj : bs_Hash.cmi
Expand All @@ -43,16 +45,26 @@ bs_HashSetInt.cmj : bs_internalSetBuckets.cmj bs_internalBucketsType.cmj \
bs_Bag.cmj :
bs_BagM.cmj :
bs_Cmp.cmj : bs_Cmp.cmi
bs_Map.cmj : bs_internalAVLtree.cmj bs_Cmp.cmj bs_Bag.cmj bs_Array.cmj \
bs_Map.cmi
bs_MapString.cmj : bs_internalAVLtree.cmj bs_Array.cmj bs_MapString.cmi
bs_MapInt.cmj : bs_internalAVLtree.cmj bs_Array.cmj bs_MapInt.cmi
bs_Map.cmj : bs_internalAVLtree.cmj bs_Cmp.cmj bs_Bag.cmj bs_Map.cmi
bs_internalMapInt.cmj : bs_internalAVLtree.cmj bs_Sort.cmj bs_Array.cmj
bs_internalMapString.cmj : bs_internalAVLtree.cmj bs_Sort.cmj bs_Array.cmj
bs_MapString.cmj : bs_internalMapString.cmj bs_internalAVLtree.cmj \
bs_Sort.cmj bs_Array.cmj bs_MapString.cmi
bs_MapInt.cmj : bs_internalMapInt.cmj bs_internalAVLtree.cmj bs_Sort.cmj \
bs_Array.cmj bs_MapInt.cmi
bs_MapStringM.cmj : bs_internalMapString.cmj bs_internalAVLtree.cmj \
bs_SortString.cmj bs_Array.cmj bs_MapStringM.cmi
bs_MapIntM.cmj : bs_internalMapInt.cmj bs_internalAVLtree.cmj bs_SortInt.cmj \
bs_Array.cmj bs_MapIntM.cmi
bs_Set.cmj : bs_internalAVLset.cmj bs_Cmp.cmj bs_Bag.cmj bs_Array.cmj \
bs_Set.cmi
bs_SetM.cmj : bs_internalAVLset.cmj bs_Sort.cmj bs_Cmp.cmj bs_BagM.cmj \
bs_Array.cmj bs_SetM.cmi
bs_internalSetInt.cmj : bs_internalAVLset.cmj bs_Array.cmj
bs_internalSetString.cmj : bs_internalAVLset.cmj bs_Array.cmj
bs_MapM.cmj : bs_internalAVLtree.cmj bs_Cmp.cmj bs_BagM.cmj bs_Array.cmj \
bs_MapM.cmi
bs_internalSetInt.cmj : bs_internalAVLset.cmj bs_SortInt.cmj bs_Array.cmj
bs_internalSetString.cmj : bs_internalAVLset.cmj bs_SortString.cmj \
bs_Array.cmj
bs_SetInt.cmj : bs_internalSetInt.cmj bs_internalAVLset.cmj bs_SetInt.cmi
bs_SetIntM.cmj : bs_internalSetInt.cmj bs_internalAVLset.cmj bs_SortInt.cmj \
bs_Array.cmj bs_SetIntM.cmi
Expand Down Expand Up @@ -87,7 +99,7 @@ js_result.cmi :
js_mapperRt.cmi :
bs_Array.cmi :
bs_internalAVLset.cmi : bs_Cmp.cmi
bs_internalAVLtree.cmi :
bs_internalAVLtree.cmi : bs_Cmp.cmi
bs_SetIntM.cmi :
bs_Hash.cmi :
bs_Queue.cmi :
Expand All @@ -104,8 +116,11 @@ bs_Cmp.cmi :
bs_Map.cmi : bs_Cmp.cmi bs_Bag.cmj
bs_MapString.cmi :
bs_MapInt.cmi :
bs_MapStringM.cmi :
bs_MapIntM.cmi :
bs_Set.cmi : bs_Cmp.cmi bs_Bag.cmj
bs_SetM.cmi : bs_Cmp.cmi
bs_MapM.cmi : bs_Cmp.cmi
bs_SetInt.cmi :
bs_SetIntM.cmi :
bs_SetString.cmi :
Expand Down
17 changes: 16 additions & 1 deletion jscomp/others/Design.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,19 @@ hierachy
## bs_SetIntM
## bs_SetStringM

# map
# map
## bs_internalAVLtree (basic module with rotation)

## bs_Map

## internal_map.cpp.ml
## bs_internalMapInt
## bs_internalMapString

## map.cppo.ml
## bs_MapInt
## bs_MapString

## mapm.cppo.ml
## bs_MapIntM
## bs_MapStringM
25 changes: 24 additions & 1 deletion jscomp/others/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ SOURCE_LIST= node_path node_fs node_process dict node_module js_array js_string
bs_BagM\
bs_Cmp\
bs_Map\
bs_internalMapInt\
bs_internalMapString\
bs_MapString \
bs_MapInt\
bs_MapStringM \
bs_MapIntM\
bs_internalSet\
bs_Set\
bs_SetM\
bs_MapM\
bs_internalSetInt\
bs_internalSetString\
bs_SetInt\
Expand Down Expand Up @@ -86,7 +91,13 @@ clean::
bs_internalSetInt.ml bs_internalSetString.ml \
bs_SetInt.ml bs_SetInt.mli bs_SetString.ml bs_SetString.mli \
bs_SetIntM.ml bs_SetIntM.mli bs_SetStringM.ml bs_SetStringM.mli\
bs_SortInt.ml bs_SortInt.mli bs_SortString.ml bs_SortString.mli
bs_SortInt.ml bs_SortInt.mli bs_SortString.ml bs_SortString.mli\
bs_internalMapInt.ml bs_internalMapInt.mli \
bs_internalMapIntM.ml bs_internalMapIntM.mli \
bs_internalMapString.ml bs_internalMapString.mli\
bs_internalMapStringM.ml bs_internalMapStringM.mli\
bs_MapStringM.mli bs_MapStringM.ml\
bs_MapIntM.mli bs_MapIntM.ml

ifndef BS_RELEASE_BUILD
bs_HashSetString.ml: hashset.cppo.ml
Expand All @@ -113,6 +124,18 @@ bs_MapString.mli: map.cppo.mli
cppo -D TYPE_STRING $^ > $@
bs_MapInt.mli: map.cppo.mli
cppo -D TYPE_INT $^ > $@
bs_MapStringM.mli: mapm.cppo.mli
cppo -D TYPE_STRING $^ > $@
bs_MapIntM.mli: mapm.cppo.mli
cppo -D TYPE_INT $^ > $@
bs_MapStringM.ml: mapm.cppo.ml
cppo -D TYPE_STRING $^ > $@
bs_MapIntM.ml: mapm.cppo.ml
cppo -D TYPE_INT $^ > $@
bs_internalMapInt.ml : internal_map.cppo.ml
cppo -D TYPE_INT $^ > $@
bs_internalMapString.ml : internal_map.cppo.ml
cppo -D TYPE_STRING $^ > $@
bs_internalSetInt.ml: internal_set.cppo.ml
cppo -D TYPE_INT $^ > $@
bs_internalSetString.ml: internal_set.cppo.ml
Expand Down
4 changes: 3 additions & 1 deletion jscomp/others/bs_Array.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ let swapUnsafe xs i j =
unsafe_set xs j tmp


let shuffleInPlace xs =
let shuffleOnly xs =
let len = length xs in
for i = 0 to len - 1 do
swapUnsafe xs i (Js_math.random_int i len) (* [i,len)*)
done

let shuffle xs = shuffleOnly xs; xs

let makeMatrix sx sy init =
[%assert sx >=0 && sy >=0 ];
let res = makeUninitializedUnsafe sx in
Expand Down
6 changes: 5 additions & 1 deletion jscomp/others/bs_Array.mli
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ external makeUninitializedUnsafe : int -> 'a array = "Array" [@@bs.new]

val init : int -> (int -> 'a [@bs]) -> 'a array

val shuffleInPlace : 'a array -> unit
val shuffleOnly : 'a array -> unit

val shuffle :'a array -> 'a array
(** [shuffle xs] it mutates [xs] and return
[xs] for chaining
*)
val zip : 'a array -> 'b array -> ('a * 'b) array
(** [zip a b] stop with the shorter array *)

Expand Down

0 comments on commit ad93c75

Please sign in to comment.