diff options
-rw-r--r-- | byterun/mlvalues.h | 5 | ||||
-rw-r--r-- | byterun/obj.c | 5 |
2 files changed, 7 insertions, 3 deletions
diff --git a/byterun/mlvalues.h b/byterun/mlvalues.h index 110c808eb..d6263aefc 100644 --- a/byterun/mlvalues.h +++ b/byterun/mlvalues.h @@ -188,8 +188,11 @@ typedef opcode_t * code_t; #define Class_val(val) Field((val), 0) #define Oid_val(val) Long_val(Field((val), 1)) CAMLextern value caml_get_public_method (value obj, value tag); -/* called as: +/* Called as: caml_callback(caml_get_public_method(obj, caml_hash_variant(name)), obj) */ +/* caml_get_public_method returns 0 if tag not in the table. + Note however that tags being hashed, same tag does not necessarily mean + same method name. */ /* Special case of tuples of fields: closures */ #define Closure_tag 247 diff --git a/byterun/obj.c b/byterun/obj.c index 3ee12201e..6332e4de9 100644 --- a/byterun/obj.c +++ b/byterun/obj.c @@ -189,7 +189,7 @@ CAMLprim value caml_lazy_make_forward (value v) CAMLreturn (res); } -/* For camlinternalOO.ml +/* For mlvalues.h and camlinternalOO.ml See also GETPUBMET in interp.c */ @@ -202,7 +202,8 @@ CAMLprim value caml_get_public_method (value obj, value tag) if (tag < Field(meths,mi)) hi = mi-2; else li = mi; } - return Field (meths, li-1); + /* return 0 if tag is not there */ + return (tag == Field(meths,li) ? Field (meths, li-1) : 0); } /* these two functions might be useful to an hypothetical JIT */ |