Skip to content

Commit e2d421b

Browse files
committed
exception_handlers encoded with objects
1 parent ab00b69 commit e2d421b

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

runtime/js/effect.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ var caml_current_stack = {};
5353
//Requires: caml_current_stack
5454
//If: effects
5555
function caml_push_trap(handler) {
56-
caml_current_stack.x = [handler, caml_current_stack.x];
56+
caml_current_stack.x = {h:handler,t:caml_current_stack.x};
5757
}
5858

5959
//Provides: caml_pop_trap
@@ -64,8 +64,8 @@ function caml_pop_trap() {
6464
return function (x) {
6565
throw x;
6666
};
67-
var h = caml_current_stack.x[0];
68-
caml_current_stack.x = caml_current_stack.x[1];
67+
var h = caml_current_stack.x.h;
68+
caml_current_stack.x = caml_current_stack.x.t;
6969
return h;
7070
}
7171

@@ -201,7 +201,7 @@ function caml_alloc_stack(hv, hx, hf) {
201201
// Call [hx] in the parent fiber
202202
return call(2, e);
203203
}
204-
return { k: hval, x: [hexn, 0], h: handlers, e: 0 };
204+
return { k: hval, x: {h:hexn,t:0}, h: handlers, e: 0 };
205205
}
206206

207207
//Provides: caml_alloc_stack

runtime/js/jslib.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ function caml_callback(f, args) {
105105
} catch (e) {
106106
/* Handle exception coming from JavaScript or from the runtime. */
107107
if (!caml_current_stack.x) throw e;
108-
var handler = caml_current_stack.x[0];
109-
caml_current_stack.x = caml_current_stack.x[1];
108+
var handler = caml_current_stack.x.h;
109+
caml_current_stack.x = caml_current_stack.x.t;
110110
res = { joo_tramp: handler, joo_args: [caml_wrap_exception(e)] };
111111
}
112112
} while (res && res.joo_args);

0 commit comments

Comments
 (0)