Skip to content

Commit

Permalink
depercate old verbose code
Browse files Browse the repository at this point in the history
  • Loading branch information
Hongbo Zhang committed May 18, 2016
1 parent 3ef50b8 commit f480471
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 306 deletions.
74 changes: 35 additions & 39 deletions jscomp/js_exp_make.ml
Original file line number Diff line number Diff line change
Expand Up @@ -783,52 +783,48 @@ let bind ?comment fn obj : t =

let public_method_call meth_name obj label cache args =
let len = List.length args in
(** FIXME: not caml object *)


econd (int_equal (tag obj ) obj_int_tag_literal)
(
if len <= 7 then
runtime_call Js_config.curry
("js" ^ string_of_int (len + 1) )
(label:: ( int cache) :: obj::args)
else
runtime_call Js_config.curry "js"
[label;
int cache;
obj ;
arr NA (obj::args)
]
)
(* econd (int_equal (tag obj ) obj_int_tag_literal) *)
if len <= 7 then
runtime_call Js_config.curry
("js" ^ string_of_int (len + 1) )
(label:: ( int cache) :: obj::args)
else
runtime_call Js_config.curry "js"
[label;
int cache;
obj ;
arr NA (obj::args)
]

(* TODO: handle arbitrary length of args ..
we can reduce part of the overhead by using
`__js` -- a easy ppx {{ x ##.hh }}
the downside is that no way to swap ocaml/js implementation
for object part, also need encode arity..
how about x#|getElementById|2|
*)
(
let fn = bind (dot obj meth_name) obj in
if len = 0 then
dot obj meth_name
(* Note that when no args supplied,
it is not necessarily a function, [bind]
is dangerous
so if user write such code
{[
let u = x # say in
u 3
]}
It's reasonable to drop [this] support
*)
else if len <=8 then
let len_str = string_of_int len in
runtime_call Js_config.curry (Literals.app ^len_str)
(fn :: args)
else
runtime_call Js_config.curry Literals.app_array
[fn ; arr NA args ]
)
(* ( *)
(* let fn = bind (dot obj meth_name) obj in *)
(* if len = 0 then *)
(* dot obj meth_name *)
(* (\* Note that when no args supplied, *)
(* it is not necessarily a function, [bind] *)
(* is dangerous *)
(* so if user write such code *)
(* {[ *)
(* let u = x # say in *)
(* u 3 *)
(* ]} *)
(* It's reasonable to drop [this] support *)
(* *\) *)
(* else if len <=8 then *)
(* let len_str = string_of_int len in *)
(* runtime_call Js_config.curry (Literals.app ^len_str) *)
(* (fn :: args) *)
(* else *)
(* runtime_call Js_config.curry Literals.app_array *)
(* [fn ; arr NA args ] *)
(* ) *)

let set_tag ?comment e tag : t =
seq {expression_desc = Caml_block_set_tag (e,tag); comment } unit
Expand Down
120 changes: 25 additions & 95 deletions lib/js/test/class3_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var point = CamlinternalOO.make_class(shared$1, point_init);

var p = Curry._2(point[0], 0, 7);

eq('File "class3_test.ml", line 17, characters 12-19', p.tag === 248 ? Curry.js1(291546447, 1, p) : p.get_x, 7);
eq('File "class3_test.ml", line 17, characters 12-19', Curry.js1(291546447, 1, p), 7);

function adjusted_point_init($$class) {
var origin = CamlinternalOO.new_variable($$class, "");
Expand Down Expand Up @@ -146,7 +146,7 @@ var adjusted_point = CamlinternalOO.make_class(shared$4, adjusted_point_init);

var tmp = Curry._2(adjusted_point[0], 0, 31);

eq('File "class3_test.ml", line 28, characters 13-20', tmp.tag === 248 ? Curry.js1(291546447, 2, tmp) : tmp.get_x, 30);
eq('File "class3_test.ml", line 28, characters 13-20', Curry.js1(291546447, 2, tmp), 30);

function new_init(obj_init, self, x_init) {
return Curry._2(obj_init, self, Caml_int32.imul(x_init / 10 | 0, 10));
Expand Down Expand Up @@ -181,7 +181,7 @@ var adjusted_point2 = [

var tmp$1 = Curry._2(adjusted_point2_000, 0, 31);

eq('File "class3_test.ml", line 33, characters 12-19', tmp$1.tag === 248 ? Curry.js1(291546447, 3, tmp$1) : tmp$1.get_x, 30);
eq('File "class3_test.ml", line 33, characters 12-19', Curry.js1(291546447, 3, tmp$1), 30);

function printable_point_init($$class) {
var ids = CamlinternalOO.new_methods_variables($$class, shared$8, shared$5);
Expand Down Expand Up @@ -215,7 +215,7 @@ var printable_point = CamlinternalOO.make_class(shared$6, printable_point_init);

var p$1 = Curry._2(printable_point[0], 0, 7);

eq('File "class3_test.ml", line 49, characters 11-18', p$1.tag === 248 ? Curry.js1(-930392019, 4, p$1) : p$1.print, 7);
eq('File "class3_test.ml", line 49, characters 11-18', Curry.js1(-930392019, 4, p$1), 7);

var ints = [/* [] */0];

Expand Down Expand Up @@ -252,21 +252,11 @@ CamlinternalOO.init_class($$class);

var my_int = CamlinternalOO.create_object_opt(0, $$class);

if (my_int.tag === 248) {
Curry.js1(-794843549, 5, my_int);
}
else {
my_int.register;
}
Curry.js1(-794843549, 5, my_int);

if (my_int.tag === 248) {
Curry.js1(-794843549, 6, my_int);
}
else {
my_int.register;
}
Curry.js1(-794843549, 6, my_int);

console.log(my_int.tag === 248 ? Curry.js1(5393365, 7, my_int) : my_int.len);
console.log(Curry.js1(5393365, 7, my_int));

var v = /* int array */[
0,
Expand Down Expand Up @@ -370,14 +360,9 @@ var vpoint = CamlinternalOO.make_class(shared$4, vpoint_init);

var h = Curry._2(vpoint[0], 0, 3);

if (h.tag === 248) {
Curry.js2(-933174511, 8, h, 32);
}
else {
Curry._1(h.move.bind(h), 32);
}
Curry.js2(-933174511, 8, h, 32);

var v$1 = h.tag === 248 ? Curry.js1(-792262820, 9, h) : h.get_offset;
var v$1 = Curry.js1(-792262820, 9, h);

eq('File "class3_test.ml", line 107, characters 12-19', v$1, 32);

Expand Down Expand Up @@ -428,14 +413,9 @@ var point2 = CamlinternalOO.make_class([

var h$1 = Curry._2(point2[0], 0, 3);

if (h$1.tag === 248) {
Curry.js2(-933174511, 10, h$1, 32);
}
else {
Curry._1(h$1.move.bind(h$1), 32);
}
Curry.js2(-933174511, 10, h$1, 32);

var vv = h$1.tag === 248 ? Curry.js1(-792262820, 11, h$1) : h$1.get_offset;
var vv = Curry.js1(-792262820, 11, h$1);

eq('File "class3_test.ml", line 128, characters 12-19', vv, 32);

Expand Down Expand Up @@ -478,14 +458,9 @@ var restricted_point = CamlinternalOO.make_class([

var p$2 = Curry._2(restricted_point[0], 0, 0);

if (p$2.tag === 248) {
Curry.js1(-1054863370, 12, p$2);
}
else {
p$2.bump;
}
Curry.js1(-1054863370, 12, p$2);

var h$2 = p$2.tag === 248 ? Curry.js1(291546447, 13, p$2) : p$2.get_x;
var h$2 = Curry.js1(291546447, 13, p$2);

eq('File "class3_test.ml", line 144, characters 12-19', h$2, 1);

Expand All @@ -504,28 +479,13 @@ var point_again = CamlinternalOO.make_class(shared$9, point_again_init);

var p$3 = Curry._2(point_again[0], 0, 3);

if (p$3.tag === 248) {
Curry.js2(-933174511, 14, p$3, 3);
}
else {
Curry._1(p$3.move.bind(p$3), 3);
}
Curry.js2(-933174511, 14, p$3, 3);

if (p$3.tag === 248) {
Curry.js1(-1054863370, 15, p$3);
}
else {
p$3.bump;
}
Curry.js1(-1054863370, 15, p$3);

if (p$3.tag === 248) {
Curry.js1(-1054863370, 16, p$3);
}
else {
p$3.bump;
}
Curry.js1(-1054863370, 16, p$3);

var hh = p$3.tag === 248 ? Curry.js1(291546447, 17, p$3) : p$3.get_x;
var hh = Curry.js1(291546447, 17, p$3);

eq('File "class3_test.ml", line 161, characters 12-19', hh, 8);

Expand All @@ -543,28 +503,13 @@ var point_again2 = CamlinternalOO.make_class(shared$9, point_again2_init);

var p$4 = Curry._2(point_again2[0], 0, 3);

if (p$4.tag === 248) {
Curry.js2(-933174511, 18, p$4, 30);
}
else {
Curry._1(p$4.move.bind(p$4), 30);
}
Curry.js2(-933174511, 18, p$4, 30);

if (p$4.tag === 248) {
Curry.js1(-1054863370, 19, p$4);
}
else {
p$4.bump;
}
Curry.js1(-1054863370, 19, p$4);

if (p$4.tag === 248) {
Curry.js1(-1054863370, 20, p$4);
}
else {
p$4.bump;
}
Curry.js1(-1054863370, 20, p$4);

var hhh = p$4.tag === 248 ? Curry.js1(291546447, 21, p$4) : p$4.get_x;
var hhh = Curry.js1(291546447, 21, p$4);

eq('File "class3_test.ml", line 177, characters 12-19', hhh, 35);

Expand All @@ -587,28 +532,13 @@ var point_again3 = CamlinternalOO.make_class(shared$9, point_again3_init);

var p$5 = Curry._2(point_again3[0], 0, 3);

if (p$5.tag === 248) {
Curry.js2(-933174511, 22, p$5, 300);
}
else {
Curry._1(p$5.move.bind(p$5), 300);
}
Curry.js2(-933174511, 22, p$5, 300);

if (p$5.tag === 248) {
Curry.js1(-1054863370, 23, p$5);
}
else {
p$5.bump;
}
Curry.js1(-1054863370, 23, p$5);

if (p$5.tag === 248) {
Curry.js1(-1054863370, 24, p$5);
}
else {
p$5.bump;
}
Curry.js1(-1054863370, 24, p$5);

var hhhh = p$5.tag === 248 ? Curry.js1(291546447, 25, p$5) : p$5.get_x;
var hhhh = Curry.js1(291546447, 25, p$5);

eq('File "class3_test.ml", line 195, characters 12-19', hhhh, 305);

Expand Down
15 changes: 4 additions & 11 deletions lib/js/test/class4_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,25 +192,18 @@ eq('File "class4_test.ml", line 67, characters 5-12', /* tuple */[
5,
"red"
], /* tuple */[
p$prime.tag === 248 ? Curry.js1(291546447, 1, p$prime) : p$prime.get_x,
p$prime.tag === 248 ? Curry.js1(-899911325, 2, p$prime) : p$prime.color
Curry.js1(291546447, 1, p$prime),
Curry.js1(-899911325, 2, p$prime)
]);

function get_succ_x(p) {
return (
p.tag === 248 ? Curry.js1(291546447, 3, p) : p.get_x
) + 1 | 0;
return Curry.js1(291546447, 3, p) + 1 | 0;
}

eq('File "class4_test.ml", line 71, characters 12-19', 6, get_succ_x(p$prime));

function set_x(p) {
if (p.tag === 248) {
return Curry.js1(-97543333, 4, p);
}
else {
return p.set_x;
}
return Curry.js1(-97543333, 4, p);
}

function incr(p) {
Expand Down
Loading

0 comments on commit f480471

Please sign in to comment.