|
Ruby
2.0.0p481(2014-05-08revision45883)
|
#include "ruby/ruby.h"#include "ruby/util.h"#include "internal.h"#include "dln.h"#include "eval_intern.h"#include "probes.h"#include "node.h"
Go to the source code of this file.
Data Structures | |
| struct | loaded_feature_searching |
Defines | |
| #define | numberof(array) (int)(sizeof(array) / sizeof((array)[0])) |
| #define | IS_RBEXT(e) (strcmp((e), ".rb") == 0) |
| #define | IS_SOEXT(e) (strcmp((e), ".so") == 0 || strcmp((e), ".o") == 0) |
| #define | IS_DLEXT(e) (strcmp((e), DLEXT) == 0) |
| #define | rb_intern(str) rb_intern2((str), strlen(str)) |
Enumerations | |
| enum | expand_type { EXPAND_ALL, EXPAND_RELATIVE, EXPAND_HOME, EXPAND_NON_CACHE } |
Functions | |
| VALUE | rb_get_load_path (void) |
| static void | rb_construct_expanded_load_path (int type, int *has_relative, int *has_non_cache) |
| static VALUE | load_path_getcwd (void) |
| VALUE | rb_get_expanded_load_path (void) |
| static VALUE | load_path_getter (ID id, rb_vm_t *vm) |
| static VALUE | get_loaded_features (void) |
| static void | reset_loaded_features_snapshot (void) |
| static struct st_table * | get_loaded_features_index_raw (void) |
| static st_table * | get_loading_table (void) |
| static void | features_index_add_single (VALUE short_feature, VALUE offset) |
| static void | features_index_add (VALUE feature, VALUE offset) |
| static int | loaded_features_index_clear_i (st_data_t key, st_data_t val, st_data_t arg) |
| static st_table * | get_loaded_features_index (void) |
| static VALUE | loaded_feature_path (const char *name, long vlen, const char *feature, long len, int type, VALUE load_path) |
| static int | loaded_feature_path_i (st_data_t v, st_data_t b, st_data_t f) |
| static int | rb_feature_p (const char *feature, const char *ext, int rb, int expanded, const char **fn) |
| int | rb_provided (const char *feature) |
| int | rb_feature_provided (const char *feature, const char **loading) |
| static void | rb_provide_feature (VALUE feature) |
| void | rb_provide (const char *feature) |
| NORETURN (static void load_failed(VALUE)) | |
| static void | rb_load_internal (VALUE fname, int wrap) |
| void | rb_load (VALUE fname, int wrap) |
| void | rb_load_protect (VALUE fname, int wrap, int *state) |
| static VALUE | rb_f_load (int argc, VALUE *argv) |
| static char * | load_lock (const char *ftptr) |
| static int | release_thread_shield (st_data_t *key, st_data_t *value, st_data_t done, int existing) |
| static void | load_unlock (const char *ftptr, int done) |
| VALUE | rb_f_require (VALUE obj, VALUE fname) |
| VALUE | rb_f_require_relative (VALUE obj, VALUE fname) |
| static int | search_required (VALUE fname, volatile VALUE *path, int safe_level) |
| static void | load_failed (VALUE fname) |
| static VALUE | load_ext (VALUE path) |
| VALUE | rb_require_safe (VALUE fname, int safe) |
| VALUE | rb_require (const char *fname) |
| static int | register_init_ext (st_data_t *key, st_data_t *value, st_data_t init, int existing) |
| RUBY_FUNC_EXPORTED void | ruby_init_ext (const char *name, void(*init)(void)) |
| static VALUE | rb_mod_autoload (VALUE mod, VALUE sym, VALUE file) |
| static VALUE | rb_mod_autoload_p (VALUE mod, VALUE sym) |
| static VALUE | rb_f_autoload (VALUE obj, VALUE sym, VALUE file) |
| static VALUE | rb_f_autoload_p (VALUE obj, VALUE sym) |
| void | Init_load () |
Variables | |
| VALUE | ruby_dln_librefs |
| static const char *const | loadable_ext [] |
| #define IS_DLEXT | ( | e | ) | (strcmp((e), DLEXT) == 0) |
Definition at line 22 of file load.c.
Referenced by loaded_feature_path(), rb_feature_p(), rb_feature_provided(), and search_required().
| #define IS_RBEXT | ( | e | ) | (strcmp((e), ".rb") == 0) |
Definition at line 17 of file load.c.
Referenced by loaded_feature_path(), rb_feature_p(), rb_feature_provided(), and search_required().
| #define IS_SOEXT | ( | e | ) | (strcmp((e), ".so") == 0 || strcmp((e), ".o") == 0) |
Definition at line 18 of file load.c.
Referenced by rb_feature_p(), rb_feature_provided(), and search_required().
Definition at line 15 of file load.c.
Referenced by features_index_add_single(), and rb_feature_p().
| #define rb_intern | ( | str | ) | rb_intern2((str), strlen(str)) |
| enum expand_type |
| static void features_index_add | ( | VALUE | feature, |
| VALUE | offset | ||
| ) | [static] |
Definition at line 227 of file load.c.
References features_index_add_single(), NULL, rb_str_subseq(), RSTRING_LEN, and StringValuePtr.
Referenced by get_loaded_features_index(), and rb_provide_feature().
| static void features_index_add_single | ( | VALUE | short_feature, |
| VALUE | offset | ||
| ) | [static] |
Definition at line 188 of file load.c.
References Check_Type, get_loaded_features_index_raw(), NIL_P, numberof, Qnil, rb_ary_cat(), rb_ary_push(), rb_ary_tmp_new(), RB_TYPE_P, ruby_strdup(), st_insert(), st_lookup(), StringValueCStr, T_ARRAY, T_FIXNUM, and T_STRING.
Referenced by features_index_add().
| static VALUE get_loaded_features | ( | void | ) | [static] |
Definition at line 163 of file load.c.
References GET_VM.
Referenced by Init_load(), rb_feature_p(), and rb_provide_feature().
| static st_table* get_loaded_features_index | ( | void | ) | [static] |
Definition at line 273 of file load.c.
References features_index_add(), GET_VM, INT2FIX, rb_vm_struct::loaded_features, rb_vm_struct::loaded_features_index, loaded_features_index_clear_i(), rb_vm_struct::loaded_features_snapshot, RARRAY_LEN, rb_ary_entry(), rb_ary_shared_with_p(), rb_ary_store(), rb_str_freeze(), reset_loaded_features_snapshot(), st_foreach(), and StringValue.
Referenced by rb_feature_p().
| static struct st_table* get_loaded_features_index_raw | ( | void | ) | [static, read] |
Definition at line 176 of file load.c.
References GET_VM.
Referenced by features_index_add_single().
| static st_table* get_loading_table | ( | void | ) | [static] |
Definition at line 182 of file load.c.
References GET_VM.
Referenced by load_lock(), load_unlock(), rb_feature_p(), and ruby_init_ext().
| void Init_load | ( | ) |
Definition at line 1148 of file load.c.
References get_loaded_features(), GET_VM, load_path_getter(), rb_alias_variable(), rb_ary_new(), rb_ary_tmp_new(), rb_cModule, rb_define_global_function(), rb_define_hooked_variable(), rb_define_method(), rb_define_virtual_variable(), rb_f_autoload(), rb_f_autoload_p(), rb_f_load(), rb_f_require(), rb_f_require_relative(), rb_gc_register_mark_object(), rb_gvar_readonly_setter(), rb_intern, rb_intern2(), rb_mod_autoload(), rb_mod_autoload_p(), ruby_dln_librefs, and st_init_strtable().
Definition at line 927 of file load.c.
References dln_load(), NOEX_PUBLIC, RSTRING_PTR, and SCOPE_SET.
Referenced by rb_require_safe().
| static void load_failed | ( | VALUE | fname | ) | [static] |
Definition at line 921 of file load.c.
References rb_load_fail().
Referenced by rb_f_load(), rb_load(), and rb_require_safe().
Definition at line 704 of file load.c.
References get_loading_table(), GET_VM, nd_type, NODE_MEMO, Qfalse, Qnil, rb_backtrace(), rb_thread_shield_new(), rb_thread_shield_wait(), RB_TYPE_P, rb_warning(), RNODE, RTEST, ruby_strdup(), ruby_verbose, st_init_strtable(), st_insert(), st_lookup(), and T_NODE.
Referenced by rb_require_safe().
| static VALUE load_path_getcwd | ( | void | ) | [static] |
Definition at line 102 of file load.c.
References my_getcwd, rb_filesystem_str_new_cstr(), and xfree().
Referenced by rb_get_expanded_load_path().
| static VALUE load_path_getter | ( | ID | id, |
| rb_vm_t * | vm | ||
| ) | [static] |
Definition at line 157 of file load.c.
References rb_vm_struct::load_path.
Referenced by Init_load().
| static void load_unlock | ( | const char * | ftptr, |
| int | done | ||
| ) | [static] |
Definition at line 758 of file load.c.
References get_loading_table(), key, release_thread_shield(), and st_update().
Referenced by rb_require_safe().
| static VALUE loaded_feature_path | ( | const char * | name, |
| long | vlen, | ||
| const char * | feature, | ||
| long | len, | ||
| int | type, | ||
| VALUE | load_path | ||
| ) | [static] |
Definition at line 310 of file load.c.
References IS_DLEXT, IS_RBEXT, RARRAY_LEN, RARRAY_PTR, RSTRING_LEN, and StringValuePtr.
Referenced by loaded_feature_path_i(), and rb_feature_p().
| static int loaded_feature_path_i | ( | st_data_t | v, |
| st_data_t | b, | ||
| st_data_t | f | ||
| ) | [static] |
Definition at line 362 of file load.c.
References loaded_feature_searching::len, loaded_feature_searching::load_path, loaded_feature_path(), loaded_feature_searching::name, loaded_feature_searching::result, ST_CONTINUE, ST_STOP, strlen(), and loaded_feature_searching::type.
Referenced by rb_feature_p().
| static int loaded_features_index_clear_i | ( | st_data_t | key, |
| st_data_t | val, | ||
| st_data_t | arg | ||
| ) | [static] |
Definition at line 266 of file load.c.
References ST_DELETE, and xfree().
Referenced by get_loaded_features_index().
| NORETURN | ( | static void | load_failedVALUE | ) |
| static void rb_construct_expanded_load_path | ( | int | type, |
| int * | has_relative, | ||
| int * | has_non_cache | ||
| ) | [static] |
Definition at line 53 of file load.c.
References EXPAND_HOME, EXPAND_NON_CACHE, EXPAND_RELATIVE, rb_vm_struct::expanded_load_path, GET_VM, level, rb_vm_struct::load_path, rb_vm_struct::load_path_snapshot, Qnil, RARRAY_LEN, RARRAY_PTR, rb_ary_push(), rb_ary_replace(), rb_ary_tmp_new(), rb_file_expand_path_fast(), rb_get_path_check_convert(), rb_get_path_check_to_string(), rb_is_absolute_path(), rb_obj_freeze(), rb_safe_level, rb_str_freeze(), RB_TYPE_P, RSTRING_PTR, and T_STRING.
Referenced by rb_get_expanded_load_path().
| static VALUE rb_f_autoload | ( | VALUE | obj, |
| VALUE | sym, | ||
| VALUE | file | ||
| ) | [static] |
Definition at line 1116 of file load.c.
References NIL_P, rb_class_real(), rb_eTypeError, rb_mod_autoload(), rb_raise(), and rb_vm_cbase().
Referenced by Init_load().
| static VALUE rb_f_autoload_p | ( | VALUE | obj, |
| VALUE | sym | ||
| ) | [static] |
Definition at line 1137 of file load.c.
References NIL_P, Qnil, rb_mod_autoload_p(), and rb_vm_cbase().
Referenced by Init_load().
Definition at line 674 of file load.c.
References FilePathValue, load_failed(), Qtrue, rb_file_load_ok(), rb_find_file(), rb_load_internal(), rb_scan_args(), rb_sourcefile, rb_sourceline(), RSTRING_PTR, RTEST, and StringValuePtr.
Referenced by Init_load().
| VALUE rb_f_require | ( | VALUE | obj, |
| VALUE | fname | ||
| ) |
Definition at line 806 of file load.c.
References rb_require_safe(), and rb_safe_level.
Referenced by Init_load().
| VALUE rb_f_require_relative | ( | VALUE | obj, |
| VALUE | fname | ||
| ) |
Definition at line 820 of file load.c.
References NIL_P, rb_current_realfilepath(), rb_file_absolute_path(), rb_file_dirname(), rb_loaderror(), rb_require_safe(), and rb_safe_level.
Referenced by Init_load().
| static int rb_feature_p | ( | const char * | feature, |
| const char * | ext, | ||
| int | rb, | ||
| int | expanded, | ||
| const char ** | fn | ||
| ) | [static] |
Definition at line 374 of file load.c.
References buf, f, FIX2LONG, get_loaded_features(), get_loaded_features_index(), get_loading_table(), IS_DLEXT, IS_RBEXT, IS_SOEXT, loaded_feature_searching::len, loaded_feature_searching::load_path, loadable_ext, loaded_feature_path(), loaded_feature_path_i(), MEMCPY, loaded_feature_searching::name, NIL_P, numberof, Qnil, RARRAY_LEN, RARRAY_PTR, rb_get_expanded_load_path(), rb_str_resize(), rb_str_tmp_new(), RB_TYPE_P, loaded_feature_searching::result, RSTRING_LEN, RSTRING_PTR, st_foreach(), st_get_key(), st_lookup(), StringValuePtr, strlcpy(), strlen(), T_ARRAY, type, and loaded_feature_searching::type.
Referenced by rb_feature_provided(), and search_required().
| int rb_feature_provided | ( | const char * | feature, |
| const char ** | loading | ||
| ) |
Definition at line 523 of file load.c.
References FALSE, IS_DLEXT, IS_RBEXT, IS_SOEXT, Qnil, rb_feature_p(), rb_file_expand_path_fast(), rb_get_path(), rb_str_new2(), RSTRING_PTR, strchr(), strrchr(), and TRUE.
Referenced by autoload_provided(), and rb_provided().
| VALUE rb_get_expanded_load_path | ( | void | ) |
Definition at line 111 of file load.c.
References EXPAND_ALL, EXPAND_HOME, EXPAND_NON_CACHE, EXPAND_RELATIVE, rb_vm_struct::expanded_load_path, GET_VM, rb_vm_struct::load_path, rb_vm_struct::load_path_check_cache, load_path_getcwd(), rb_vm_struct::load_path_snapshot, Qtrue, rb_ary_shared_with_p(), rb_construct_expanded_load_path(), and rb_str_equal().
Referenced by rb_feature_p(), rb_find_file_ext_safe(), and rb_find_file_safe().
| VALUE rb_get_load_path | ( | void | ) |
Definition at line 638 of file load.c.
References FilePathValue, load_failed(), rb_find_file(), and rb_load_internal().
Referenced by rb_load_protect().
| static void rb_load_internal | ( | VALUE | fname, |
| int | wrap | ||
| ) | [static] |
Definition at line 574 of file load.c.
References rb_thread_struct::errinfo, EXEC_TAG, FALSE, FIXNUM_P, GET_THREAD(), rb_thread_struct::mild_compile_error, NIL_P, node, POP_TAG, PUSH_TAG, Qfalse, Qnil, rb_exc_raise(), rb_extend_object(), RB_GC_GUARD, rb_iseq_eval(), rb_iseq_new_top(), rb_load_file(), rb_module_new(), rb_obj_clone(), rb_realpath_internal(), rb_secure(), rb_str_new2(), rb_vm_jump_tag_but_local_jump(), rb_vm_top_self(), RSTRING_PTR, rb_thread_struct::top_self, rb_thread_struct::top_wrapper, and TRUE.
Referenced by rb_f_load(), rb_load(), and rb_require_safe().
| void rb_load_protect | ( | VALUE | fname, |
| int | wrap, | ||
| int * | state | ||
| ) |
| static VALUE rb_mod_autoload | ( | VALUE | mod, |
| VALUE | sym, | ||
| VALUE | file | ||
| ) | [static] |
Definition at line 1072 of file load.c.
References FilePathValue, Qnil, rb_autoload(), rb_to_id(), and RSTRING_PTR.
Referenced by Init_load(), and rb_f_autoload().
| static VALUE rb_mod_autoload_p | ( | VALUE | mod, |
| VALUE | sym | ||
| ) | [static] |
Definition at line 1095 of file load.c.
References Qnil, rb_autoload_p(), and rb_check_id().
Referenced by Init_load(), and rb_f_autoload_p().
| void rb_provide | ( | const char * | feature | ) |
Definition at line 566 of file load.c.
References rb_provide_feature(), and rb_usascii_str_new2().
Referenced by InitVM_Enumerator().
| static void rb_provide_feature | ( | VALUE | feature | ) | [static] |
Definition at line 549 of file load.c.
References features_index_add(), get_loaded_features(), INT2FIX, OBJ_FROZEN, RARRAY_LEN, rb_ary_push(), rb_eRuntimeError, rb_raise(), rb_str_freeze(), and reset_loaded_features_snapshot().
Referenced by rb_provide(), and rb_require_safe().
| int rb_provided | ( | const char * | feature | ) |
Definition at line 517 of file load.c.
References rb_feature_provided().
| VALUE rb_require | ( | const char * | fname | ) |
Definition at line 1024 of file load.c.
References OBJ_FREEZE, rb_require_safe(), rb_safe_level, and rb_str_new2().
Referenced by Init_bubblebabble(), Init_generator(), Init_md5(), Init_ossl_digest(), Init_parser(), Init_psych_parser(), Init_rmd160(), Init_sha1(), Init_sha2(), Init_tkutil(), and process_options().
| VALUE rb_require_safe | ( | VALUE | fname, |
| int | safe | ||
| ) |
Definition at line 934 of file load.c.
References rb_thread_struct::errinfo, EXEC_TAG, FilePathValue, GET_THREAD(), JUMP_TAG, load_ext(), load_failed(), load_lock(), load_unlock(), LONG2NUM, NIL_P, POP_TAG, PUSH_TAG, Qfalse, Qnil, Qtrue, rb_ary_push(), rb_load_internal(), rb_provide_feature(), rb_safe_level, rb_set_safe_level_force(), rb_sourcefile, rb_sourceline(), rb_vm_call_cfunc(), rb_vm_top_self(), result, RSTRING_PTR, ruby_dln_librefs, search_required(), and StringValuePtr.
Referenced by autoload_require(), load_transcoder_entry(), rb_f_require(), rb_f_require_relative(), rb_require(), and require_enc().
| static int register_init_ext | ( | st_data_t * | key, |
| st_data_t * | value, | ||
| st_data_t | init, | ||
| int | existing | ||
| ) | [static] |
Definition at line 1032 of file load.c.
References name, NEW_MEMO, rb_warn(), ruby_strdup(), and ST_CONTINUE.
Referenced by ruby_init_ext().
| static int release_thread_shield | ( | st_data_t * | key, |
| st_data_t * | value, | ||
| st_data_t | done, | ||
| int | existing | ||
| ) | [static] |
Definition at line 745 of file load.c.
References rb_thread_shield_destroy(), rb_thread_shield_release(), ST_CONTINUE, ST_DELETE, ST_STOP, and xfree().
Referenced by load_unlock().
| static void reset_loaded_features_snapshot | ( | void | ) | [static] |
Definition at line 169 of file load.c.
References GET_VM, rb_vm_struct::loaded_features, rb_vm_struct::loaded_features_snapshot, and rb_ary_replace().
Referenced by get_loaded_features_index(), and rb_provide_feature().
| RUBY_FUNC_EXPORTED void ruby_init_ext | ( | const char * | name, |
| void(*)(void) | init | ||
| ) |
Definition at line 1047 of file load.c.
References get_loading_table(), GET_VM, register_init_ext(), st_init_strtable(), and st_update().
Referenced by init_golf().
| static int search_required | ( | VALUE | fname, |
| volatile VALUE * | path, | ||
| int | safe_level | ||
| ) | [static] |
Definition at line 831 of file load.c.
References FALSE, IS_DLEXT, IS_RBEXT, IS_SOEXT, loadable_ext, OBJ_FREEZE, rb_feature_p(), rb_filesystem_str_new_cstr(), rb_find_file_ext_safe(), rb_find_file_safe(), rb_str_cat2(), rb_str_subseq(), RSTRING_PTR, strchr(), strrchr(), TRUE, and type.
Referenced by rb_require_safe().
const char* const loadable_ext[] [static] |
{
".rb", DLEXT,
0
}
Definition at line 25 of file load.c.
Referenced by rb_feature_p(), and search_required().
Definition at line 13 of file load.c.
Referenced by Init_load(), and rb_require_safe().
1.7.6.1