Skip to content

Commit 9c688ae

Browse files
author
Hongbo Zhang
committed
move ocaml_pack tools into normal source distribution
1 parent 9e4d9bc commit 9c688ae

18 files changed

+122
-121
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ _build
3333
*.zip
3434
*.gz
3535
# special file
36-
ocaml_pack
36+
3737
bsc
3838
bscc
39-
ocaml_pack0.ml
40-
ocaml_pack1.ml
39+
jscomp/tools/ocamlpack*
40+
4141
.idea
4242
exports.js
4343
node_modules

jscomp/Makefile

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ release:snapshot
3636
# TODO: should be done after we do the build
3737
# Carefully check the stored data if it is platform independent
3838

39-
./bin/ocaml_pack: ./bin/ocaml_pack.mli ./bin/ocaml_pack.ml
39+
./bin/ocamlpack: ./bin/ocamlpack.mli ./bin/ocamlpack.ml
4040
$(NATIVE) -w -a -I bin -I +compiler-libs ocamlcommon.cmxa unix.cmxa $^ -o $@
4141

42-
snapshot: ./bin/ocaml_pack snapshotcmj
42+
_build/ocamlpack: _build/ext/ext.cmxa _build/syntax/pack.cmxa _build/syntax/ocaml_pack_main.cmx
43+
$(NATIVE) -I +compiler-libs ocamlcommon.cmxa unix.cmxa $^ -o $@
44+
45+
snapshot: ./bin/ocamlpack snapshotcmj
4346
$(MAKE) snapshotml
4447

45-
snapshotml:./bin/ocaml_pack ./bin/compiler.mllib
48+
snapshotml:./bin/ocamlpack ./bin/compiler.mllib
4649
@echo "Snapshot ml"
4750
$< bin/compiler.mllib > bin/compiler.ml
4851
snapshotcmj:
@@ -85,14 +88,14 @@ world-test:
8588
cd test && $(MAKE) all
8689
@echo "Making test finsihed"
8790

88-
travis-world-test:./bin/ocaml_pack
91+
travis-world-test:./bin/ocamlpack
8992
@echo "Generating the compiler"
9093
rm -f bin/compiler.ml
91-
./bin/ocaml_pack ./bin/compiler.mllib > bin/compiler.ml
94+
./bin/ocamlpack ./bin/compiler.mllib > bin/compiler.ml
9295
@echo "Generating the compiler finished"
9396
$(MAKE) world-test
9497

95-
# no depend on ./bin/ocaml_pack ./bin/bsc
98+
# no depend on ./bin/ocamlpack ./bin/bsc
9699
# since in npm mode, they are generated from a single file
97100
install:
98101
cp ./bin/bsc ../bin/

jscomp/bin/.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
ppx_metaquot
2-
ocaml_pack
2+
ocamlpack
33
bsc

jscomp/bin/ocaml_pack.ml renamed to jscomp/bin/ocamlpack.ml

Lines changed: 89 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(** Bundled by ocaml_pack 06/20-16:36 *)
1+
(** Bundled by ocamlpack 08/10-10:46 *)
22
module Ext_bytes : sig
33
#1 "ext_bytes.mli"
44
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -452,6 +452,11 @@ val invalid_argf : ('a, unit, string, 'b) format4 -> 'a
452452

453453
val bad_argf : ('a, unit, string, 'b) format4 -> 'a
454454

455+
456+
457+
val dump : 'a -> string
458+
459+
455460
end = struct
456461
#1 "ext_pervasives.ml"
457462
(* Copyright (C) 2015-2016 Bloomberg Finance L.P.
@@ -525,6 +530,88 @@ let invalid_argf fmt = Format.ksprintf invalid_arg fmt
525530
let bad_argf fmt = Format.ksprintf (fun x -> raise (Arg.Bad x ) ) fmt
526531

527532

533+
let rec dump r =
534+
if Obj.is_int r then
535+
string_of_int (Obj.magic r : int)
536+
else (* Block. *)
537+
let rec get_fields acc = function
538+
| 0 -> acc
539+
| n -> let n = n-1 in get_fields (Obj.field r n :: acc) n
540+
in
541+
let rec is_list r =
542+
if Obj.is_int r then
543+
r = Obj.repr 0 (* [] *)
544+
else
545+
let s = Obj.size r and t = Obj.tag r in
546+
t = 0 && s = 2 && is_list (Obj.field r 1) (* h :: t *)
547+
in
548+
let rec get_list r =
549+
if Obj.is_int r then
550+
[]
551+
else
552+
let h = Obj.field r 0 and t = get_list (Obj.field r 1) in
553+
h :: t
554+
in
555+
let opaque name =
556+
(* XXX In future, print the address of value 'r'. Not possible
557+
* in pure OCaml at the moment. *)
558+
"<" ^ name ^ ">"
559+
in
560+
let s = Obj.size r and t = Obj.tag r in
561+
(* From the tag, determine the type of block. *)
562+
match t with
563+
| _ when is_list r ->
564+
let fields = get_list r in
565+
"[" ^ String.concat "; " (List.map dump fields) ^ "]"
566+
| 0 ->
567+
let fields = get_fields [] s in
568+
"(" ^ String.concat ", " (List.map dump fields) ^ ")"
569+
| x when x = Obj.lazy_tag ->
570+
(* Note that [lazy_tag .. forward_tag] are < no_scan_tag. Not
571+
* clear if very large constructed values could have the same
572+
* tag. XXX *)
573+
opaque "lazy"
574+
| x when x = Obj.closure_tag ->
575+
opaque "closure"
576+
| x when x = Obj.object_tag ->
577+
let fields = get_fields [] s in
578+
let _clasz, id, slots =
579+
match fields with
580+
| h::h'::t -> h, h', t
581+
| _ -> assert false
582+
in
583+
(* No information on decoding the class (first field). So just print
584+
* out the ID and the slots. *)
585+
"Object #" ^ dump id ^ " (" ^ String.concat ", " (List.map dump slots) ^ ")"
586+
| x when x = Obj.infix_tag ->
587+
opaque "infix"
588+
| x when x = Obj.forward_tag ->
589+
opaque "forward"
590+
| x when x < Obj.no_scan_tag ->
591+
let fields = get_fields [] s in
592+
"Tag" ^ string_of_int t ^
593+
" (" ^ String.concat ", " (List.map dump fields) ^ ")"
594+
| x when x = Obj.string_tag ->
595+
"\"" ^ String.escaped (Obj.magic r : string) ^ "\""
596+
| x when x = Obj.double_tag ->
597+
string_of_float (Obj.magic r : float)
598+
| x when x = Obj.abstract_tag ->
599+
opaque "abstract"
600+
| x when x = Obj.custom_tag ->
601+
opaque "custom"
602+
| x when x = Obj.custom_tag ->
603+
opaque "final"
604+
| x when x = Obj.double_array_tag ->
605+
"[|"^
606+
String.concat ";"
607+
(Array.to_list (Array.map string_of_float (Obj.magic r : float array))) ^
608+
"|]"
609+
| _ ->
610+
opaque (Printf.sprintf "unknown: tag %d size %d" t s)
611+
612+
let dump v = dump (Obj.repr v)
613+
614+
528615
end
529616
module Line_process : sig
530617
#1 "line_process.mli"
@@ -1413,7 +1500,7 @@ let _ =
14131500
begin
14141501
let local_time = Unix.(localtime (gettimeofday ())) in
14151502
output_string stdout
1416-
(Printf.sprintf {|(** Bundled by ocaml_pack %02d/%02d-%02d:%02d *)|}
1503+
(Printf.sprintf {|(** Bundled by ocamlpack %02d/%02d-%02d:%02d *)|}
14171504
(local_time.tm_mon + 1) local_time.tm_mday
14181505
local_time.tm_hour local_time.tm_min
14191506
);
File renamed without changes.

jscomp/build.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
"trigger", ".", {
33
"name": "build",
4-
"expression": ["pcre", "(\\.(ml|mlp|mll|mly|mli|sh|mk|sh|mllib)$|bsc$|Makefile)"],
4+
"expression": ["pcre", "(\\.(ml|mlp|mll|mly|mli|sh|itarget|mk|sh|mllib)$|bsc$|Makefile)"],
55
"command": ["./build.sh"],
66
"append_files" : true
77
}

jscomp/foo.itarget

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
common/common.cmxa
22
ext/ext.cmxa
33
syntax/syntax.cmxa
4-
core.cmxa
4+
core.cmxa
5+
syntax/pack.cmxa
6+
syntax/ocaml_pack_main.cmx
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)