Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions jscomp/core/lam.ml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ type primitive =
(* Operations on heap blocks *)
| Pmakeblock of int * tag_info * mutable_flag
| Pfield of int * field_dbg_info
| Psetfield of int * bool * set_field_dbg_info
| Psetfield of int * set_field_dbg_info
(* could have field info at least for record *)
| Pfloatfield of int * field_dbg_info
| Psetfloatfield of int * set_field_dbg_info
Expand Down Expand Up @@ -1555,7 +1555,7 @@ let lam_prim ~primitive:( p : Lambda.primitive) ~args loc : t =
-> prim ~primitive:(Pfield (id,info)) ~args loc

| Psetfield (id,b,info)
-> prim ~primitive:(Psetfield (id,b,info)) ~args loc
-> prim ~primitive:(Psetfield (id,info)) ~args loc

| Pfloatfield (id,info)
-> prim ~primitive:(Pfloatfield (id,info)) ~args loc
Expand Down Expand Up @@ -1857,7 +1857,7 @@ let convert exports lam : _ * _ =
| "#makemutablelist" ->
Pmakeblock(0,Lambda.Blk_constructor("::",1),Mutable)
| "#setfield1" ->
Psetfield(1, true, Fld_set_na)
Psetfield(1, Fld_set_na)
| "#undefined_to_opt" -> Pundefined_to_opt
| "#null_undefined_to_opt" -> Pnull_undefined_to_opt
| "#null_to_opt" -> Pnull_to_opt
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/lam.mli
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type primitive =
| Pglobal_exception of ident
| Pmakeblock of int * Lambda.tag_info * Asttypes.mutable_flag
| Pfield of int * Lambda.field_dbg_info
| Psetfield of int * bool * Lambda.set_field_dbg_info
| Psetfield of int * Lambda.set_field_dbg_info
| Pfloatfield of int * Lambda.field_dbg_info
| Psetfloatfield of int * Lambda.set_field_dbg_info
| Pduprecord of Types.record_representation * int
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/lam_analysis.ml
Original file line number Diff line number Diff line change
Expand Up @@ -546,7 +546,7 @@ and eq_primitive ( lhs : Lam.primitive) (rhs : Lam.primitive) =
| Pcaml_obj_set_length -> rhs = Pcaml_obj_set_length
| Pccall {prim_name = n0 ; prim_native_name = nn0} -> (match rhs with Pccall {prim_name = n1; prim_native_name = nn1} -> n0 = n1 && nn0 = nn1 | _ -> false )
| Pfield (n0, _dbg_info0) -> (match rhs with Pfield (n1, _dbg_info1) -> n0 = n1 | _ -> false )
| Psetfield(i0, b0, _dbg_info0) -> (match rhs with Psetfield(i1, b1, _dbg_info1) -> i0 = i1 && b0 = b1 | _ -> false)
| Psetfield(i0, _dbg_info0) -> (match rhs with Psetfield(i1, _dbg_info1) -> i0 = i1 | _ -> false)
| Pglobal_exception ident -> (match rhs with Pglobal_exception ident2 -> Ident.same ident ident2 | _ -> false )
| Pmakeblock (i, _tag_info, mutable_flag) -> (match rhs with Pmakeblock(i1,_,mutable_flag1) -> i = i1 && mutable_flag = mutable_flag1 | _ -> false)
| Pfloatfield (i0,_dbg_info) -> (match rhs with Pfloatfield (i1,_) -> i0 = i1 | _ -> false)
Expand Down
2 changes: 1 addition & 1 deletion jscomp/core/lam_compile_primitive.ml
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ let translate loc
| [e] -> E.array_length e
| _ -> assert false
end
| Psetfield (i, _, field_info) ->
| Psetfield (i, field_info) ->
begin match args with
| [e0;e1] -> (** RUNTIME *)
decorate_side_effect cxt
Expand Down
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 @@ -49,7 +49,7 @@ let rec eliminate_ref id (lam : Lam.t) =
TODO: we can refine analysis in later
*)
(* Lfunction(kind, params, eliminate_ref id body) *)
| Lprim {primitive = Psetfield(0, _,_);
| Lprim {primitive = Psetfield(0,_);
args = [Lvar v; e]} when Ident.same v id ->
Lam.assign id (eliminate_ref id e)
| Lprim {primitive = Poffsetref delta ;
Expand Down
6 changes: 3 additions & 3 deletions jscomp/core/lam_print.ml
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ let primitive ppf (prim : Lam.primitive) = match prim with
| Pmakeblock(tag, _, Immutable) -> fprintf ppf "makeblock %i" tag
| Pmakeblock(tag, _, Mutable) -> fprintf ppf "makemutable %i" tag
| Pfield (n,_) -> fprintf ppf "field %i" n
| Psetfield(n, ptr, _) ->
let instr = if ptr then "setfield_ptr " else "setfield_imm " in
| Psetfield(n, _) ->
let instr = "setfield " in
fprintf ppf "%s%i" instr n
| Pfloatfield (n,_) -> fprintf ppf "floatfield %i" n
| Psetfloatfield (n,_) -> fprintf ppf "setfloatfield %i" n
Expand Down Expand Up @@ -418,7 +418,7 @@ let lambda use_env env ppf v =
fprintf ppf "%s.%s/%d" id.name (get_string (id,n) env) n

| Lprim {
primitive = Psetfield (n,_,_);
primitive = Psetfield (n,_);
args = [ Lglobal_module id ;
e ]
; _} when use_env ->
Expand Down
6 changes: 3 additions & 3 deletions jscomp/test/bigarray_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ function sum() {

function init(v) {
for(var i = 0 ,i_finish = Caml_missing_polyfill.not_implemented("caml_ba_dim_1") - 1 | 0; i <= i_finish; ++i){
v[i] = /* array */[
Caml_int32.imul(i, i),
Caml_int32.imul(Caml_int32.imul(i, i), i)
v[i] = /* record */[
/* re */Caml_int32.imul(i, i),
/* im */Caml_int32.imul(Caml_int32.imul(i, i), i)
];
}
return /* () */0;
Expand Down
6 changes: 3 additions & 3 deletions jscomp/test/complex_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ var suites_000 = /* tuple */[
"basic_add",
(function () {
return /* Eq */Block.__(0, [
/* array */[
2,
2
/* record */[
/* re */2,
/* im */2
],
Complex.add(Complex.add(Complex.add(Complex.one, Complex.one), Complex.i), Complex.i)
]);
Expand Down
36 changes: 30 additions & 6 deletions jscomp/test/flow_parser_reg_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4467,9 +4467,21 @@ function mem(x, _param) {

function create$1(lex_env, mode) {
var lexbuf = lex_env[/* lex_lb */1];
var newrecord = lexbuf.slice();
newrecord[/* lex_buffer */1] = lexbuf[/* lex_buffer */1];
var lex_env$1 = with_lexbuf(newrecord, lex_env);
var lexbuf$1 = /* record */[
/* refill_buff */lexbuf[/* refill_buff */0],
/* lex_buffer */lexbuf[/* lex_buffer */1],
/* lex_buffer_len */lexbuf[/* lex_buffer_len */2],
/* lex_abs_pos */lexbuf[/* lex_abs_pos */3],
/* lex_start_pos */lexbuf[/* lex_start_pos */4],
/* lex_curr_pos */lexbuf[/* lex_curr_pos */5],
/* lex_last_pos */lexbuf[/* lex_last_pos */6],
/* lex_last_action */lexbuf[/* lex_last_action */7],
/* lex_eof_reached */lexbuf[/* lex_eof_reached */8],
/* lex_mem */lexbuf[/* lex_mem */9],
/* lex_start_p */lexbuf[/* lex_start_p */10],
/* lex_curr_p */lexbuf[/* lex_curr_p */11]
];
var lex_env$1 = with_lexbuf(lexbuf$1, lex_env);
return /* record */[
/* la_results : array */[],
/* la_num_lexed */0,
Expand Down Expand Up @@ -4537,9 +4549,21 @@ function lex(t) {
}
var lex_env$1 = match$1[0];
var lexbuf = lex_env$1[/* lex_lb */1];
var newrecord = lexbuf.slice();
newrecord[/* lex_buffer */1] = lexbuf[/* lex_buffer */1];
var cloned_env = with_lexbuf(newrecord, lex_env$1);
var lexbuf$1 = /* record */[
/* refill_buff */lexbuf[/* refill_buff */0],
/* lex_buffer */lexbuf[/* lex_buffer */1],
/* lex_buffer_len */lexbuf[/* lex_buffer_len */2],
/* lex_abs_pos */lexbuf[/* lex_abs_pos */3],
/* lex_start_pos */lexbuf[/* lex_start_pos */4],
/* lex_curr_pos */lexbuf[/* lex_curr_pos */5],
/* lex_last_pos */lexbuf[/* lex_last_pos */6],
/* lex_last_action */lexbuf[/* lex_last_action */7],
/* lex_eof_reached */lexbuf[/* lex_eof_reached */8],
/* lex_mem */lexbuf[/* lex_mem */9],
/* lex_start_p */lexbuf[/* lex_start_p */10],
/* lex_curr_p */lexbuf[/* lex_curr_p */11]
];
var cloned_env = with_lexbuf(lexbuf$1, lex_env$1);
t[/* la_lex_env */3] = lex_env$1;
Caml_array.caml_array_set(t[/* la_results */0], t[/* la_num_lexed */1], /* Some */[/* tuple */[
cloned_env,
Expand Down
84 changes: 46 additions & 38 deletions jscomp/test/mario_game.js
Original file line number Diff line number Diff line change
Expand Up @@ -694,9 +694,9 @@ var Sprite = /* module */[
];

function pair_to_xy(pair) {
return /* array */[
pair[0],
pair[1]
return /* record */[
/* x */pair[0],
/* y */pair[1]
];
}

Expand Down Expand Up @@ -850,13 +850,13 @@ function make$2($staropt$star, $staropt$star$1, spawnable, context, param) {
var id$1 = id ? id[0] : new_id(/* () */0);
var obj = /* record */[
/* params */params,
/* pos : array */[
param[0],
param[1]
/* pos : record */[
/* x */param[0],
/* y */param[1]
],
/* vel : array */[
0.0,
0.0
/* vel : record */[
/* x */0.0,
/* y */0.0
],
/* id */id$1,
/* jumping */false,
Expand Down Expand Up @@ -1221,13 +1221,13 @@ function get_aabb(obj) {
var sy = match$1[1];
var sx = match$1[0];
return /* record */[
/* center : array */[
box + sx / 2,
boy + sy / 2
/* center : record */[
/* x */box + sx / 2,
/* y */boy + sy / 2
],
/* half : array */[
sx / 2,
sy / 2
/* half : record */[
/* x */sx / 2,
/* y */sy / 2
]
];
}
Expand Down Expand Up @@ -1512,17 +1512,17 @@ var Draw = /* module */[

function make$3(param, param$1) {
return /* record */[
/* pos : array */[
0,
0
/* pos : record */[
/* x */0,
/* y */0
],
/* v_dim : array */[
param[0],
param[1]
/* v_dim : record */[
/* x */param[0],
/* y */param[1]
],
/* m_dim : array */[
param$1[0],
param$1[1]
/* m_dim : record */[
/* x */param$1[0],
/* y */param$1[1]
]
];
}
Expand Down Expand Up @@ -1552,18 +1552,18 @@ function out_of_viewport_below(v, y) {
}

function coord_to_viewport(viewport, coord) {
return /* array */[
coord[/* x */0] - viewport[/* pos */0][/* x */0],
coord[/* y */1] - viewport[/* pos */0][/* y */1]
return /* record */[
/* x */coord[/* x */0] - viewport[/* pos */0][/* x */0],
/* y */coord[/* y */1] - viewport[/* pos */0][/* y */1]
];
}

function update(vpt, ctr) {
var new_x = calc_viewport_point(ctr[/* x */0], vpt[/* v_dim */1][/* x */0], vpt[/* m_dim */2][/* x */0]);
var new_y = calc_viewport_point(ctr[/* y */1], vpt[/* v_dim */1][/* y */1], vpt[/* m_dim */2][/* y */1]);
var pos = /* array */[
new_x,
new_y
var pos = /* record */[
/* x */new_x,
/* y */new_y
];
return /* record */[
/* pos */pos,
Expand Down Expand Up @@ -2234,18 +2234,26 @@ function update_loop(canvas, param, map_dim) {
if (player$1[2][/* kill */8] === true) {
return game_loss(state[/* ctx */1]);
} else {
var newrecord = state.slice();
newrecord[/* vpt */2] = update(state[/* vpt */2], player$1[2][/* pos */1]);
var state$1 = /* record */[
/* bgd */state[/* bgd */0],
/* ctx */state[/* ctx */1],
/* vpt */update(state[/* vpt */2], player$1[2][/* pos */1]),
/* map */state[/* map */3],
/* score */state[/* score */4],
/* coins */state[/* coins */5],
/* multiplier */state[/* multiplier */6],
/* game_over */state[/* game_over */7]
];
List.iter((function (obj) {
run_update_collid(newrecord, obj, objs);
run_update_collid(state$1, obj, objs);
return /* () */0;
}), objs);
List.iter((function (part) {
var state = newrecord;
var state$2 = state$1;
var part$1 = part;
$$process(part$1);
var x = part$1[/* pos */2][/* x */0] - state[/* vpt */2][/* pos */0][/* x */0];
var y = part$1[/* pos */2][/* y */1] - state[/* vpt */2][/* pos */0][/* y */1];
var x = part$1[/* pos */2][/* x */0] - state$2[/* vpt */2][/* pos */0][/* x */0];
var y = part$1[/* pos */2][/* y */1] - state$2[/* vpt */2][/* pos */0][/* y */1];
render(part$1[/* params */0][/* sprite */0], /* tuple */[
x,
y
Expand All @@ -2261,9 +2269,9 @@ function update_loop(canvas, param, map_dim) {
}
}), parts);
fps(canvas, fps$1);
hud(canvas, newrecord[/* score */4], newrecord[/* coins */5]);
hud(canvas, state$1[/* score */4], state$1[/* coins */5]);
requestAnimationFrame((function (t) {
return update_helper(t, newrecord, player$1, collid_objs[0], particles[0]);
return update_helper(t, state$1, player$1, collid_objs[0], particles[0]);
}));
return /* () */0;
}
Expand Down
Loading