Skip to content

Commit 6921a30

Browse files
committed
update the demo page source code
1 parent 088b62b commit 6921a30

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+242
-95
lines changed

jscomp/bin/compiler.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -8809,7 +8809,7 @@ include
88098809
P.string f
88108810
(match program.side_effect with
88118811
| None -> "/* No side effect */"
8812-
| Some v -> Printf.sprintf "/* %s fail the pure module */" v);
8812+
| Some v -> Printf.sprintf "/* %s Not a pure module */" v);
88138813
P.newline f;
88148814
P.flush f ()
88158815
end
@@ -10148,4 +10148,4 @@ include
1014810148
s)[@@ocaml.doc
1014910149
" {!Char.escaped} is locale sensitive in 4.02.3, fixed in the trunk,\n backport it here\n "]
1015010150
end
10151-
end
10151+
end

jscomp/js_dump.ml

+2-2
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ and
777777
if l > 2 then P.paren_vgroup f 1 action else action ()
778778

779779
| Object lst ->
780-
P.brace_group f 1 @@ fun _ ->
780+
P.brace_vgroup f 1 @@ fun _ ->
781781
property_name_and_value_list cxt f lst
782782

783783
and property_name cxt f (s : J.property_name) : Ext_pp_scope.t =
@@ -1350,7 +1350,7 @@ let pp_program (program : J.program) (f : Ext_pp.t) =
13501350
P.string f (
13511351
match program.side_effect with
13521352
| None -> "/* No side effect */"
1353-
| Some v -> Printf.sprintf "/* %s fail the pure module */" v );
1353+
| Some v -> Printf.sprintf "/* %s Not a pure module */" v );
13541354
P.newline f;
13551355
P.flush f ()
13561356

jscomp/stdlib/filename.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,4 +376,4 @@ exports.get_temp_dir_name = get_temp_dir_name;
376376
exports.set_temp_dir_name = set_temp_dir_name;
377377
exports.temp_dir_name = temp_dir_name$2;
378378
exports.quote = quote$1;
379-
/* match fail the pure module */
379+
/* match Not a pure module */

jscomp/stdlib/format.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1928,4 +1928,4 @@ exports.set_all_formatter_output_functions = set_all_formatter_output_functions;
19281928
exports.get_all_formatter_output_functions = get_all_formatter_output_functions;
19291929
exports.pp_set_all_formatter_output_functions = pp_set_all_formatter_output_functions;
19301930
exports.pp_get_all_formatter_output_functions = pp_get_all_formatter_output_functions;
1931-
/* q_elem fail the pure module */
1931+
/* q_elem Not a pure module */

jscomp/stdlib/genlex.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -839,4 +839,4 @@ function make_lexer(keywords) {
839839
}
840840

841841
exports.make_lexer = make_lexer;
842-
/* Hashtbl fail the pure module */
842+
/* Hashtbl Not a pure module */

jscomp/stdlib/hashtbl.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -794,4 +794,4 @@ exports.hash = hash;
794794
exports.seeded_hash = seeded_hash;
795795
exports.hash_param = hash_param;
796796
exports.seeded_hash_param = seeded_hash_param;
797-
/* randomized_default fail the pure module */
797+
/* randomized_default Not a pure module */

jscomp/stdlib/moreLabels.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ var $$Set$1 = $$Set;
1313
exports.Hashtbl = Hashtbl$1;
1414
exports.$$Map = $$Map$1;
1515
exports.$$Set = $$Set$1;
16-
/* Hashtbl fail the pure module */
16+
/* Hashtbl Not a pure module */

jscomp/stdlib/scanf.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2145,4 +2145,4 @@ exports.bscanf_format = bscanf_format;
21452145
exports.sscanf_format = sscanf_format;
21462146
exports.format_from_string = format_from_string;
21472147
exports.unescaped = unescaped;
2148-
/* stdin fail the pure module */
2148+
/* stdin Not a pure module */

jscomp/stdlib/std_exit.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ var Pervasives = require("./pervasives");
44

55
Pervasives.do_at_exit(/* () */0);
66

7-
/* fail the pure module */
7+
/* Not a pure module */

jscomp/test/.depend

+4
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ cps_test.cmo : mt.cmo ../stdlib/array.cmi
5656
cps_test.cmx : mt.cmx ../stdlib/array.cmx
5757
demo.cmo :
5858
demo.cmx :
59+
demo_page.cmo :
60+
demo_page.cmx :
5961
equal_exception_test.cmo : ../stdlib/string.cmi mt.cmo ../stdlib/bytes.cmi
6062
equal_exception_test.cmx : ../stdlib/string.cmx mt.cmx ../stdlib/bytes.cmx
6163
ext_bytes.cmo : ../stdlib/bytes.cmi
@@ -384,6 +386,8 @@ cps_test.cmo : mt.cmo ../stdlib/array.cmi
384386
cps_test.cmo : mt.cmo ../stdlib/array.cmo
385387
demo.cmo :
386388
demo.cmo :
389+
demo_page.cmo :
390+
demo_page.cmo :
387391
equal_exception_test.cmo : ../stdlib/string.cmi mt.cmo ../stdlib/bytes.cmi
388392
equal_exception_test.cmo : ../stdlib/string.cmo mt.cmo ../stdlib/bytes.cmo
389393
ext_bytes.cmo : ../stdlib/bytes.cmi

jscomp/test/a.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ function add(x, y) {
77

88
add(1, 2);
99

10-
/* fail the pure module */
10+
/* Not a pure module */

jscomp/test/a_filename_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ var suites = [
2020
Mt.from_suites("a_filename_test.ml", suites);
2121

2222
exports.suites = suites;
23-
/* fail the pure module */
23+
/* Not a pure module */

jscomp/test/a_list_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,4 @@ var suites = [
132132
Mt.from_pair_suites("a_list_test.ml", suites);
133133

134134
exports.suites = suites;
135-
/* fail the pure module */
135+
/* Not a pure module */

jscomp/test/a_recursive_type.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ var non_terminate = g(x);
1919

2020
exports.loop = loop;
2121
exports.non_terminate = non_terminate;
22-
/* loop fail the pure module */
22+
/* loop Not a pure module */

jscomp/test/a_string_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,4 @@ Mt.from_suites("a_string_test.ml", suites);
134134
exports.split = split;
135135
exports.split_by = split_by;
136136
exports.suites = suites;
137-
/* fail the pure module */
137+
/* Not a pure module */

jscomp/test/array_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -278,4 +278,4 @@ var array_suites = [
278278

279279
Mt.from_pair_suites("array_test.ml", array_suites);
280280

281-
/* fail the pure module */
281+
/* Not a pure module */

jscomp/test/bdd.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -427,4 +427,4 @@ exports.random_vars = random_vars;
427427
exports.bool_equal = bool_equal;
428428
exports.test_hwb = test_hwb;
429429
exports.main = main;
430-
/* fail the pure module */
430+
/* Not a pure module */

jscomp/test/boolean_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ Mt.from_suites("boolean", [
1313
/* [] */0
1414
]);
1515

16-
/* fail the pure module */
16+
/* Not a pure module */

jscomp/test/buffer_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,4 +97,4 @@ Mt.from_suites("buffer", suites);
9797
exports.v = v;
9898
exports.bytes_equal = bytes_equal;
9999
exports.suites = suites;
100-
/* fail the pure module */
100+
/* Not a pure module */

jscomp/test/const_block_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,4 @@ exports.c = c;
107107
exports.v = v;
108108
exports.f = f;
109109
exports.h = h;
110-
/* fail the pure module */
110+
/* Not a pure module */

jscomp/test/cps_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,4 @@ Mt.from_suites("cps_test.ml", [
115115
exports.test = test;
116116
exports.test_closure = test_closure;
117117
exports.test_closure2 = test_closure2;
118-
/* fail the pure module */
118+
/* Not a pure module */

jscomp/test/demo.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,15 @@ function ui_layout(compile, lookup, appContext) {
5050
stackPanel.addChild(inputCode);
5151
stackPanel.addChild(button);
5252
var mk_titleRow = function (text) {
53-
return {"label": {"text": text}};
53+
return {
54+
"label": {
55+
"text": text
56+
}
57+
};
58+
};
59+
var u = {
60+
"width": 200
5461
};
55-
var u = {"width": 200};
5662
grid.minHeight = 300;
5763
grid.titleRows = /* array */[
5864
mk_titleRow("Ticker"),
@@ -92,8 +98,10 @@ function ui_layout(compile, lookup, appContext) {
9298
var price = param[2];
9399
var bid = price + 20 * Math.random();
94100
var ask = price + 20 * Math.random();
95-
var result = computeFunction[1]({"bid": bid,
96-
"ask": ask});
101+
var result = computeFunction[1]({
102+
"bid": bid,
103+
"ask": ask
104+
});
97105
return /* array */[
98106
mk_titleRow(param[1]),
99107
mk_titleRow(fmt(bid)),
@@ -107,4 +115,4 @@ function ui_layout(compile, lookup, appContext) {
107115

108116
exports.data = data;
109117
exports.ui_layout = ui_layout;
110-
/* @blp/ui fail the pure module */
118+
/* @blp/ui Not a pure module */

jscomp/test/demo_page.d.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export var fib: (n : any) => any ;
2+
export var sum: (n : any) => any ;
3+
export var map: (f : any, param : any) => any ;
4+
export var test_curry: (x : any, y : any) => any ;
5+
export var f: (y : any) => any ;
6+

jscomp/test/demo_page.js

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Generated CODE, PLEASE EDIT WITH CARE
2+
"use strict";
3+
var React = require("react");
4+
var ReactDom = require("react-dom");
5+
6+
function fib(n) {
7+
return 1 < (-1 + n >>> 0) ? fib(n - 1) + fib(n - 2) : 1;
8+
}
9+
10+
function sum(n) {
11+
var v = 0;
12+
for(var i = 0; i<= n; ++i){
13+
v += i;
14+
}
15+
return v;
16+
}
17+
18+
function map(f, param) {
19+
return param ? [
20+
/* Cons */0,
21+
f(param[1]),
22+
map(f, param[2])
23+
] : /* Nil */0;
24+
}
25+
26+
function test_curry(x, y) {
27+
return x + y;
28+
}
29+
30+
function f(param) {
31+
return test_curry(32, param);
32+
}
33+
34+
ReactDom.render(React.createClass({
35+
"render": function () {
36+
return React.DOM.div({
37+
"alt": "pic"
38+
}, React.DOM.h1(null, "hello react"), React.DOM.h2(null, "type safe!"));
39+
}
40+
}), document.getElementById("hi"));
41+
42+
exports.fib = fib;
43+
exports.sum = sum;
44+
exports.map = map;
45+
exports.test_curry = test_curry;
46+
exports.f = f;
47+
/* Not a pure module */

jscomp/test/demo_page.ml

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
let rec fib = function
2+
| 1 | 2 -> 1
3+
| n -> fib (n - 1 ) + fib (n - 2)
4+
(** Imperative style *)
5+
let sum n =
6+
let v = ref 0 in
7+
for i = 0 to n do
8+
v := !v + i
9+
done;
10+
!v
11+
(** List map *)
12+
type 'a list =
13+
| Nil
14+
| Cons of 'a * 'a list
15+
16+
let rec map f = function
17+
| Nil -> Nil
18+
| Cons (x,xs) -> Cons (f x, map f xs)
19+
20+
(** Test curry and uncurry calling convention *)
21+
let test_curry x y = x + y
22+
let f = test_curry 32
23+
24+
(** Create a typed binding for react *)
25+
type t
26+
type element
27+
external document : unit -> t = "" [@@js.global "document"] [@@js.scope "window"]
28+
external getElementById : t -> string -> element = "" [@@js.send "getElementById"]
29+
30+
(** Phantom types *)
31+
type config
32+
type component
33+
type attrs
34+
type component_class
35+
36+
external config :
37+
?display_name:string ->
38+
render:(unit -> component) -> unit ->
39+
config = "" [@@js.obj ] (** make a json object *)
40+
external attrs:
41+
?alt: string ->
42+
?autoPlay: bool ->
43+
unit -> attrs = "" [@@js.obj]
44+
external str : string -> component = "%identity"
45+
external h1 : ?attrs:attrs -> component array -> component = ""
46+
[@@js.call "h1"] [@@js.scope "DOM"] [@@js.module "react"] [@@js.splice] (** splice the last argument *)
47+
external h2 : ?attrs:attrs -> component array -> component = ""
48+
[@@js.call "h2"] [@@js.scope "DOM"] [@@js.module "react"] [@@js.splice]
49+
external div : ?attrs:attrs -> component array -> component = ""
50+
[@@js.call "div"] [@@js.scope "DOM"] [@@js.module "react"] [@@js.splice]
51+
external createClass :
52+
config -> component_class = "createClass"
53+
[@@js.call "createClass"]
54+
[@@js.module "react"]
55+
external render : component_class -> element -> unit = ""
56+
[@@js.call "render"]
57+
[@@js.module "react-dom"]
58+
;;
59+
(** Do the rendering *)
60+
render (
61+
createClass (
62+
(config
63+
~render:(fun _ ->
64+
div
65+
~attrs:(attrs ~alt:"pic" ())
66+
[|
67+
h1 [| str "hello react"|];
68+
h2 [| str "type safe!" |];
69+
|]
70+
)
71+
()))) (getElementById (document ()) "hi")

jscomp/test/equal_exception_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,4 @@ exports.is_exception = is_exception;
165165
exports.is_normal_exception = is_normal_exception;
166166
exports.is_arbitrary_exception = is_arbitrary_exception;
167167
exports.suites = suites;
168-
/* fail the pure module */
168+
/* Not a pure module */

jscomp/test/ext_filename.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,4 @@ exports.chop_extension = chop_extension;
128128
exports.try_chop_extension = try_chop_extension;
129129
exports.relative_path = relative_path;
130130
exports.node_relative_path = node_relative_path;
131-
/* Filename fail the pure module */
131+
/* Filename Not a pure module */

jscomp/test/for_side_effect_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ Mt.from_suites("for_side_effect_test.ml", suites);
3838
exports.tst = tst;
3939
exports.test2 = test2;
4040
exports.suites = suites;
41-
/* fail the pure module */
41+
/* Not a pure module */

jscomp/test/google_closure_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ Mt.from_suites("Closure", [
2929
/* [] */0
3030
]);
3131

32-
/* fail the pure module */
32+
/* Not a pure module */

jscomp/test/hashtbl_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -107,4 +107,4 @@ exports.to_list = to_list;
107107
exports.f = f;
108108
exports.g = g;
109109
exports.suites = suites;
110-
/* fail the pure module */
110+
/* Not a pure module */

jscomp/test/lexer_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,4 @@ exports.get_tokens = get_tokens;
258258
exports.f = f;
259259
exports.from_tokens = from_tokens;
260260
exports.lexer_suites = lexer_suites;
261-
/* fail the pure module */
261+
/* Not a pure module */

jscomp/test/list_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,4 @@ var list_suites = [
151151
Mt.from_suites("List_suites", list_suites);
152152

153153
exports.list_suites = list_suites;
154-
/* fail the pure module */
154+
/* Not a pure module */

jscomp/test/loop_suites_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ var Mt = require("./mt");
55

66
Mt.from_pair_suites("for_loop_test", For_loop_test.suites);
77

8-
/* fail the pure module */
8+
/* Not a pure module */

jscomp/test/map_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -463,4 +463,4 @@ var int_map_suites = [
463463

464464
Mt.from_suites("map_test", int_map_suites);
465465

466-
/* fail the pure module */
466+
/* Not a pure module */

jscomp/test/mt.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ function from_pair_suites(name, suites) {
3030
exports.assert_equal = assert_equal;
3131
exports.from_suites = from_suites;
3232
exports.from_pair_suites = from_pair_suites;
33-
/* assert fail the pure module */
33+
/* assert Not a pure module */

jscomp/test/obj_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -403,4 +403,4 @@ exports.uu = uu;
403403
exports.uuu = uuu;
404404
exports.vvvv = vvvv;
405405
exports.suites = suites;
406-
/* class fail the pure module */
406+
/* class Not a pure module */

jscomp/test/of_string_test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ var suites = [
5454
Mt.from_pair_suites("of_string_test.ml", suites);
5555

5656
exports.suites = suites;
57-
/* fail the pure module */
57+
/* Not a pure module */

0 commit comments

Comments
 (0)