Skip to content

Instantly share code, notes, and snippets.

@methodmissing
Created August 11, 2009 10:15
Show Gist options
  • Select an option

  • Save methodmissing/165736 to your computer and use it in GitHub Desktop.

Select an option

Save methodmissing/165736 to your computer and use it in GitHub Desktop.
static int
rb_const_defined_0(klass, id, exclude, recurse)
VALUE klass;
ID id;
int exclude, recurse;
{
VALUE value, tmp;
int mod_retry = 0;
tmp = klass;
retry:
while (tmp) {
if (RCLASS(tmp)->iv_tbl && st_lookup(RCLASS(tmp)->iv_tbl, id, &value)) {
if (value == Qundef && NIL_P(autoload_file(klass, id)))
return Qfalse;
return Qtrue;
}
if (!recurse && klass != rb_cObject) break;
tmp = RCLASS(tmp)->super;
}
if (!exclude && !mod_retry && BUILTIN_TYPE(klass) == T_MODULE) {
mod_retry = 1;
tmp = rb_cObject;
goto retry;
}
return Qfalse;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment