|
18 | 18 |
|
19 | 19 | (* Author: Hongbo Zhang *)
|
20 | 20 |
|
21 |
| -type exception_block = int * string * int |
22 |
| -let out_of_memory = 248, "Out_of_memory", 0 |
23 |
| -let sys_error = 248, "Sys_error", -1 |
24 |
| -let failure = 248, "Failure", -2 |
25 |
| -let invalid_argument = 248, "Invalid_argument", -3 |
26 |
| -let end_of_file = 248, "End_of_file",-4 |
27 |
| -let division_by_zero = 248, "Division_by_zero", -5 |
28 |
| -let not_found = 248, "Not_found", -6 |
29 |
| -let match_failure = 248, "Match_failure", -7 |
30 |
| -let stack_overflow = 248, "Stack_overflow",-8 |
31 |
| -let sys_blocked_io = 248, "Sys_blocked_io", -9 |
32 |
| -let assert_failure = 248, "Assert_failure", -10 |
33 |
| -let undefined_recursive_module = 248, "Undefined_recursive_module", -11 |
34 |
| - |
35 |
| - |
36 |
| - |
37 |
| -(* Exported for better inlining *) |
38 |
| -(* It's common that we have <code> a = caml_set_oo_id([248,"string",0])</code> *) |
39 |
| -(* This can be inlined as <code> a = caml_set_oo_id([248,"tag", caml_oo_last_id++])</code> *) |
40 |
| - (* @type {number} *) |
41 |
| - |
42 |
| -let id = ref 0n |
43 |
| - |
44 |
| - |
45 |
| -(* see #251 |
46 |
| - {[ |
47 |
| - CAMLprim value caml_set_oo_id (value obj) { |
48 |
| - Field(obj, 1) = oo_last_id; |
49 |
| - oo_last_id += 2; |
50 |
| - return obj; |
51 |
| - } |
52 |
| -
|
53 |
| - ]}*) |
54 |
| -let caml_set_oo_id (b : exception_block) = |
55 |
| - Obj.set_field (Obj.repr b) 1 (Obj.repr !id); |
56 |
| - id := Nativeint.add !id 1n; |
57 |
| - b |
58 |
| - |
59 |
| -let get_id () = |
60 |
| - id := Nativeint.add !id 1n; !id |
| 21 | +type exception_block = string * nativeint |
| 22 | + |
| 23 | + |
| 24 | +let out_of_memory = "Out_of_memory", 0n |
| 25 | +let sys_error = "Sys_error", -1n |
| 26 | +let failure = "Failure", -2n |
| 27 | +let invalid_argument = "Invalid_argument", -3n |
| 28 | +let end_of_file = "End_of_file",-4n |
| 29 | +let division_by_zero = "Division_by_zero", -5n |
| 30 | +let not_found = "Not_found", -6n |
| 31 | +let match_failure = "Match_failure", -7n |
| 32 | +let stack_overflow = "Stack_overflow",-8n |
| 33 | +let sys_blocked_io = "Sys_blocked_io", -9n |
| 34 | +let assert_failure = "Assert_failure", -10n |
| 35 | +let undefined_recursive_module = "Undefined_recursive_module", -11n |
| 36 | + |
| 37 | +(* TODO: |
| 38 | + 1. is it necessary to tag [248] here |
| 39 | + 2. is it okay to remove the negative value |
| 40 | +*) |
0 commit comments