Ruby
2.5.0dev(2017-10-22revision60238)
|
#include "internal.h"
#include "ruby/st.h"
#include "ruby/util.h"
#include "id_table.h"
#include "constant.h"
#include "id.h"
#include "ccan/list/list.h"
#include "debug_counter.h"
Go to the source code of this file.
Data Structures | |
struct | gen_ivtbl |
struct | ivar_update |
struct | fc_result |
struct | trace_var |
struct | rb_global_variable |
struct | trace_data |
struct | obj_ivar_tag |
struct | gen_ivar_tag |
struct | givar_copy |
struct | autoload_state |
struct | autoload_data_i |
struct | autoload_const_set_args |
Macros | |
#define | rb_is_constant_id rb_is_const_id |
#define | rb_is_constant_name rb_is_const_name |
#define | id_for_var(obj, name, part, type) id_for_var_message(obj, name, type, "`%1$s' is not allowed as "#part" "#type" variable name") |
#define | id_for_var_message(obj, name, type, message) check_id_type(obj, &(name), rb_is_##type##_id, rb_is_##type##_name, message, strlen(message)) |
#define | check_autoload_table(av) (struct st_table *)rb_check_typeddata((av), &autoload_data_type) |
#define | check_autoload_data(av) (struct autoload_data_i *)rb_check_typeddata((av), &autoload_data_i_type) |
#define | CVAR_FOREACH_ANCESTORS(klass, v, r) |
#define | CVAR_LOOKUP(v, r) |
Typedefs | |
typedef VALUE(* | path_cache_func) (VALUE obj, VALUE name) |
Variables | |
struct rb_id_table * | rb_global_tbl |
#define check_autoload_data | ( | av | ) | (struct autoload_data_i *)rb_check_typeddata((av), &autoload_data_i_type) |
Definition at line 1882 of file variable.c.
#define check_autoload_table | ( | av | ) | (struct st_table *)rb_check_typeddata((av), &autoload_data_type) |
Definition at line 1825 of file variable.c.
#define CVAR_FOREACH_ANCESTORS | ( | klass, | |
v, | |||
r | |||
) |
Definition at line 2833 of file variable.c.
#define CVAR_LOOKUP | ( | v, | |
r | |||
) |
Definition at line 2840 of file variable.c.
Referenced by rb_cvar_defined(), rb_cvar_get(), and rb_cvar_set().
#define id_for_var | ( | obj, | |
name, | |||
part, | |||
type | |||
) | id_for_var_message(obj, name, type, "`%1$s' is not allowed as "#part" "#type" variable name") |
Definition at line 1645 of file variable.c.
Referenced by rb_mod_remove_const(), and rb_obj_remove_instance_variable().
#define id_for_var_message | ( | obj, | |
name, | |||
type, | |||
message | |||
) | check_id_type(obj, &(name), rb_is_##type##_id, rb_is_##type##_name, message, strlen(message)) |
Definition at line 1647 of file variable.c.
Referenced by rb_mod_remove_cvar().
#define rb_is_constant_id rb_is_const_id |
Definition at line 1643 of file variable.c.
#define rb_is_constant_name rb_is_const_name |
Definition at line 1644 of file variable.c.
void Init_var_tables | ( | void | ) |
Definition at line 49 of file variable.c.
References rb_id_table_create(), and st_init_numtable.
NORETURN | ( | static void | uninitialized_constantVALUE, VALUE | ) |
Definition at line 912 of file variable.c.
References ALLOC, rb_global_variable::block_trace, rb_global_variable::counter, rb_global_entry::id, trace_var::next, rb_eRuntimeError, rb_global_entry(), rb_id_table_insert(), rb_id_table_lookup(), rb_raise(), rb_global_variable::trace, rb_global_entry::var, and xfree().
Definition at line 1266 of file variable.c.
Definition at line 1224 of file variable.c.
References Qnil, and rb_ivar_lookup().
Referenced by rb_error_frozen_object(), rb_refinement_module_get_refined_class(), rb_singleton_class_internal_p(), and ruby_th_dtrace_setup().
Definition at line 1886 of file variable.c.
References rb_autoload_str(), rb_eArgError, rb_fstring_cstr(), and rb_raise().
Definition at line 2151 of file variable.c.
Definition at line 2201 of file variable.c.
Definition at line 1895 of file variable.c.
References Check_Type, PRIsVALUE, Qundef, QUOTE_ID, rb_const_lookup(), rb_const_set(), rb_eArgError, rb_eNameError, rb_is_const_id(), rb_raise(), RCLASS_IV_TBL, RSTRING_LEN, st_data_t, st_lookup, T_STRING, and rb_const_entry_struct::value.
Referenced by rb_autoload().
Definition at line 2015 of file variable.c.
Definition at line 450 of file variable.c.
References fc_result::path.
Referenced by rb_clear_method_cache_by_class(), and rb_obj_classname().
Definition at line 3104 of file variable.c.
References RCLASS_IV_TBL.
Referenced by rb_singleton_class_attached().
Definition at line 444 of file variable.c.
References rb_class_path(), and rb_class_real().
Referenced by rb_any_to_s(), rb_const_warn_if_deprecated(), rb_cvar_get(), and rb_cvar_set().
Definition at line 295 of file variable.c.
References fc_result::path.
Referenced by rb_class_name(), rb_define_class_id_under(), and rb_thread_current_status().
Definition at line 319 of file variable.c.
References Qnil, RCLASS_IV_TBL, st_data_t, and st_lookup.
Definition at line 310 of file variable.c.
References fc_result::path.
Referenced by rb_vm_inc_const_missing_count(), and ruby_th_dtrace_setup().
Definition at line 2537 of file variable.c.
Referenced by Init_cparse(), rb_define_class(), and rb_define_module().
Definition at line 2543 of file variable.c.
Referenced by rb_const_remove(), rb_define_class_id_under(), and rb_define_module_id_under().
Definition at line 2531 of file variable.c.
Definition at line 2292 of file variable.c.
Referenced by generic_to_value(), Init_cparse(), Init_objspace(), rb_define_class(), and rb_define_module().
Definition at line 2298 of file variable.c.
Referenced by Init_cparse(), rb_define_class_id_under(), and rb_define_module_id_under().
Definition at line 2286 of file variable.c.
VALUE rb_const_list | ( | void * | data | ) |
Definition at line 2449 of file variable.c.
References st_table::num_entries, rb_ary_new2, and st_foreach_safe().
Referenced by rb_mod_constants().
rb_const_entry_t* rb_const_lookup | ( | VALUE | klass, |
ID | id | ||
) |
Definition at line 3128 of file variable.c.
References rb_id_table_lookup(), RCLASS_CONST_TBL, and val.
Referenced by rb_autoload_str(), rb_const_remove(), and rb_deprecate_constant().
Definition at line 1747 of file variable.c.
References rb_funcallv, rb_intern, and rb_vm_inc_const_missing_count().
Definition at line 2344 of file variable.c.
References ID2SYM, Qundef, rb_check_frozen, rb_clear_constant_cache(), rb_const_defined_at(), rb_const_lookup(), rb_id_table_delete(), rb_name_err_raise, RCLASS_CONST_TBL, val, and rb_const_entry_struct::value.
Referenced by rb_mod_remove_const().
Definition at line 2573 of file variable.c.
References NIL_P, PRIsVALUE, QUOTE_ID, rb_eTypeError, rb_raise(), and RCLASS_CONST_TBL.
Referenced by rb_autoload_str(), rb_define_class(), rb_define_class_id_under(), rb_define_const(), rb_define_module(), and rb_define_module_id_under().
void rb_const_warn_if_deprecated | ( | const rb_const_entry_t * | ce, |
VALUE | klass, | ||
ID | id | ||
) |
Definition at line 2216 of file variable.c.
References PRIsVALUE, QUOTE_ID, rb_class_name(), rb_cObject, RB_CONST_DEPRECATED_P, and rb_warn().
Definition at line 1502 of file variable.c.
References FL_EXIVAR, FL_TEST, FL_UNSET, rb_check_frozen, and rb_free_generic_ivar().
Definition at line 2932 of file variable.c.
Definition at line 2925 of file variable.c.
Definition at line 2906 of file variable.c.
References CVAR_LOOKUP, Qfalse, and Qtrue.
Referenced by rb_mod_remove_cvar().
Definition at line 2879 of file variable.c.
References CVAR_LOOKUP, id, ID2SYM, PRIsVALUE, QUOTE_ID, rb_class_name(), rb_name_err_raise, rb_warning(), RTEST, ruby_verbose, st_data_t, and autoload_data_i::value.
Definition at line 2846 of file variable.c.
References CVAR_LOOKUP, id, PRIsVALUE, QUOTE_ID, rb_class_name(), rb_warning(), RTEST, ruby_verbose, and st_data_t.
Definition at line 2939 of file variable.c.
Definition at line 2691 of file variable.c.
References rb_const_set(), rb_intern, rb_is_const_id(), and rb_warn().
Referenced by exp1(), Init_Bignum(), Init_fcntl(), Init_fiddle(), Init_fiddle_function(), Init_limits(), Init_openssl(), Init_ossl_config(), Init_sizeof(), Init_win32ole_variant_m(), rb_define_global_const(), and rb_file_const().
Definition at line 2702 of file variable.c.
References rb_cObject, and rb_define_const().
void rb_define_hooked_variable | ( | const char * | name, |
VALUE * | var, | ||
VALUE(*)(ANYARGS) | getter, | ||
void(*)(ANYARGS) | setter | ||
) |
Definition at line 617 of file variable.c.
References Qnil.
Referenced by Init_load(), rb_define_readonly_variable(), rb_define_variable(), rb_define_virtual_variable(), and ruby_prog_init().
Definition at line 642 of file variable.c.
References rb_define_hooked_variable(), and rb_gvar_readonly_setter().
Definition at line 636 of file variable.c.
References rb_define_hooked_variable().
void rb_define_virtual_variable | ( | const char * | name, |
VALUE(*)(ANYARGS) | getter, | ||
void(*)(ANYARGS) | setter | ||
) |
Definition at line 648 of file variable.c.
References rb_global_variable::getter, rb_define_hooked_variable(), rb_gvar_readonly_setter(), rb_gvar_val_getter(), and rb_global_variable::setter.
Referenced by Init_eval(), Init_safe(), and InitVM_process().
Definition at line 2749 of file variable.c.
References CONST_DEPRECATED, rb_const_entry_struct::flag, id, len, NULL, rb_check_id_cstr(), rb_const_lookup(), rb_frozen_class_p(), rb_fstring_new(), rb_name_err_raise, and strlen().
Referenced by Init_Bignum().
VALUE rb_f_global_variables | ( | void | ) |
Definition at line 884 of file variable.c.
References rb_ary_new(), rb_backref_get(), rb_id_table_foreach(), and sym.
Definition at line 688 of file variable.c.
References ALLOC, trace_var::func, trace_var::next, NIL_P, OBJ_TAINTED, rb_block_proc(), rb_eSecurityError, rb_f_untrace_var(), rb_global_entry(), rb_raise(), rb_scan_args(), rb_to_id(), rb_global_variable::trace, and rb_global_entry::var.
Definition at line 747 of file variable.c.
References rb_global_variable::block_trace, trace_var::data, id, trace_var::next, NIL_P, PRIsVALUE, QUOTE, QUOTE_ID, rb_ary_new(), rb_ary_push(), rb_check_id(), rb_id_table_lookup(), rb_name_error(), rb_name_error_str(), rb_scan_args(), trace_var::removed, and rb_global_entry::var.
Referenced by rb_f_trace_var().
void rb_free_generic_ivar | ( | VALUE | obj | ) |
Definition at line 1133 of file variable.c.
References RUBY_FUNC_EXPORTED, st_data_t, st_delete, st_free_table, and xfree().
Referenced by rb_copy_generic_ivar().
void rb_gc_mark_global_tbl | ( | void | ) |
Definition at line 594 of file variable.c.
References rb_id_table_foreach_values().
RUBY_FUNC_EXPORTED size_t rb_generic_ivar_memsize | ( | VALUE | obj | ) |
Definition at line 1150 of file variable.c.
struct rb_global_entry* rb_global_entry | ( | ID | id | ) |
Definition at line 482 of file variable.c.
References ALLOC, rb_global_variable::block_trace, rb_global_variable::counter, rb_global_variable::data, rb_global_variable::getter, id, rb_global_entry::id, rb_global_variable::marker, rb_gvar_undef_getter(), rb_gvar_undef_marker(), rb_gvar_undef_setter(), rb_id_table_insert(), rb_id_table_lookup(), rb_global_variable::setter, rb_global_variable::trace, and rb_global_entry::var.
Referenced by rb_alias_variable(), rb_f_trace_var(), rb_gv_get(), and rb_gv_set().
Definition at line 851 of file variable.c.
References rb_global_entry().
Definition at line 842 of file variable.c.
References rb_global_entry().
VALUE rb_gvar_defined | ( | struct rb_global_entry * | entry | ) |
Definition at line 860 of file variable.c.
References rb_global_variable::getter, Qfalse, Qtrue, rb_gvar_undef_getter(), and rb_global_entry::var.
VALUE rb_gvar_get | ( | struct rb_global_entry * | entry | ) |
Definition at line 792 of file variable.c.
References rb_global_variable::data, rb_global_variable::getter, rb_global_entry::id, and rb_global_entry::var.
void rb_gvar_readonly_setter | ( | VALUE | v, |
ID | id, | ||
void * | d, | ||
struct rb_global_variable * | g | ||
) |
Definition at line 572 of file variable.c.
References PRIsVALUE, QUOTE_ID, and rb_name_error().
Referenced by rb_define_readonly_variable(), and rb_define_virtual_variable().
VALUE rb_gvar_set | ( | struct rb_global_entry * | entry, |
VALUE | val | ||
) |
Definition at line 825 of file variable.c.
References rb_global_variable::block_trace, rb_global_variable::data, rb_global_entry::id, rb_ensure(), rb_global_variable::setter, rb_global_variable::trace, trace_data::trace, trace_data::val, val, and rb_global_entry::var.
VALUE rb_gvar_undef_getter | ( | ID | id, |
void * | data, | ||
struct rb_global_variable * | var | ||
) |
Definition at line 510 of file variable.c.
References PRIsVALUE, Qnil, QUOTE_ID, and rb_warning().
Referenced by rb_global_entry(), and rb_gvar_defined().
void rb_gvar_undef_marker | ( | VALUE * | var | ) |
Definition at line 528 of file variable.c.
Referenced by rb_global_entry().
void rb_gvar_undef_setter | ( | VALUE | val, |
ID | id, | ||
void * | d, | ||
struct rb_global_variable * | var | ||
) |
Definition at line 518 of file variable.c.
References rb_global_variable::data, rb_global_variable::getter, rb_global_variable::marker, rb_gvar_val_getter(), rb_gvar_val_marker(), rb_gvar_val_setter(), and rb_global_variable::setter.
Referenced by rb_global_entry().
VALUE rb_gvar_val_getter | ( | ID | id, |
void * | data, | ||
struct rb_global_variable * | var | ||
) |
Definition at line 533 of file variable.c.
Referenced by rb_define_virtual_variable(), and rb_gvar_undef_setter().
void rb_gvar_val_marker | ( | VALUE * | var | ) |
Definition at line 545 of file variable.c.
References rb_gc_mark_maybe().
Referenced by rb_gvar_undef_setter().
void rb_gvar_val_setter | ( | VALUE | val, |
ID | id, | ||
void * | data, | ||
struct rb_global_variable * | var | ||
) |
Definition at line 539 of file variable.c.
References rb_global_variable::data.
Referenced by rb_gvar_undef_setter().
VALUE rb_gvar_var_getter | ( | ID | id, |
void * | data, | ||
struct rb_global_variable * | gvar | ||
) |
Definition at line 552 of file variable.c.
References Qnil, and rb_global_entry::var.
void rb_gvar_var_marker | ( | VALUE * | var | ) |
Definition at line 566 of file variable.c.
References rb_gc_mark_maybe().
void rb_gvar_var_setter | ( | VALUE | val, |
ID | id, | ||
void * | data, | ||
struct rb_global_variable * | g | ||
) |
Definition at line 560 of file variable.c.
Definition at line 3087 of file variable.c.
References rb_intern, and rb_ivar_get().
Definition at line 3095 of file variable.c.
References rb_intern, and rb_ivar_set().
Referenced by Init_md5(), Init_rmd160(), and Init_sha1().
st_index_t rb_ivar_count | ( | VALUE | obj | ) |
Definition at line 1566 of file variable.c.
References BUILTIN_TYPE, count, FL_EXIVAR, FL_TEST, gen_ivtbl::ivptr, st_table::num_entries, Qundef, RCLASS_IV_TBL, ROBJECT_IV_INDEX_TBL, ROBJECT_IVPTR, ROBJECT_NUMIV, SPECIAL_CONST_P, T_CLASS, T_MODULE, and T_OBJECT.
Definition at line 1374 of file variable.c.
References BUILTIN_TYPE, FL_EXIVAR, FL_TEST, Qfalse, Qtrue, Qundef, RCLASS_IV_TBL, ROBJECT_IV_INDEX_TBL, ROBJECT_IVPTR, ROBJECT_NUMIV, SPECIAL_CONST_P, st_data_t, st_lookup, T_CLASS, T_MODULE, T_OBJECT, and val.
Definition at line 1544 of file variable.c.
References BUILTIN_TYPE, SPECIAL_CONST_P, and T_OBJECT.
Referenced by rb_obj_instance_variables().
Definition at line 1210 of file variable.c.
References PRIsVALUE, Qnil, Qundef, QUOTE_ID, RB_DEBUG_COUNTER_INC, rb_ivar_lookup(), rb_warning(), RTEST, and ruby_verbose.
Referenced by rb_frozen_class_p(), rb_iv_get(), rb_method_name_error(), and rb_singleton_class_get().
Definition at line 1175 of file variable.c.
References BUILTIN_TYPE, FL_EXIVAR, FL_TEST, len, Qundef, RCLASS_IV_TBL, ROBJECT_IV_INDEX_TBL, ROBJECT_IVPTR, ROBJECT_NUMIV, SPECIAL_CONST_P, st_data_t, st_lookup, T_CLASS, T_MODULE, T_OBJECT, and val.
Referenced by rb_attr_get(), and rb_ivar_get().
Definition at line 1315 of file variable.c.
References BUILTIN_TYPE, ivar_update::iv_extended, ivar_update::iv_index_tbl, len, rb_check_frozen, RB_DEBUG_COUNTER_INC, T_OBJECT, and ivar_update::u.
Referenced by create_win32ole_variable(), rb_iv_set(), rb_key_err_new(), rb_name_class(), and rb_name_err_new().
void rb_mark_generic_ivar | ( | VALUE | obj | ) |
Definition at line 1123 of file variable.c.
Definition at line 3025 of file variable.c.
References Qtrue, rb_scan_args(), and RTEST.
void* rb_mod_const_at | ( | VALUE | mod, |
void * | data | ||
) |
Definition at line 2414 of file variable.c.
References rb_id_table_foreach(), RCLASS_CONST_TBL, and st_init_numtable.
Referenced by rb_mod_const_of().
Definition at line 1792 of file variable.c.
References rb_vm_pop_cfunc_frame().
void* rb_mod_const_of | ( | VALUE | mod, |
void * | data | ||
) |
Definition at line 2427 of file variable.c.
References mod, rb_cObject, rb_mod_const_at(), and RCLASS_SUPER.
Referenced by rb_mod_constants().
Definition at line 2481 of file variable.c.
References Qtrue, rb_const_list(), rb_mod_const_of(), rb_scan_args(), and RTEST.
Definition at line 2800 of file variable.c.
Definition at line 229 of file variable.c.
References fc_result::path.
Definition at line 2772 of file variable.c.
Definition at line 2786 of file variable.c.
Definition at line 2332 of file variable.c.
References id_for_var, rb_const_remove(), and rb_name_err_raise.
Definition at line 3066 of file variable.c.
References id, ID2SYM, id_for_var_message, rb_check_frozen, rb_cvar_defined(), rb_name_err_raise, RCLASS_IV_TBL, st_data_t, st_delete, and val.
Definition at line 438 of file variable.c.
References rb_ivar_set().
Referenced by rb_define_class(), and rb_define_module_id().
Definition at line 459 of file variable.c.
References CLASS_OF, and rb_class2name().
Referenced by rb_Hash().
Definition at line 1634 of file variable.c.
References rb_ary_new(), and rb_ivar_foreach().
Definition at line 1687 of file variable.c.
References BUILTIN_TYPE, FL_EXIVAR, FL_TEST, id, id_for_var, Qnil, Qundef, rb_check_frozen, RCLASS_IV_TBL, ROBJECT_IV_INDEX_TBL, ROBJECT_IVPTR, ROBJECT_NUMIV, st_data_t, st_delete, st_lookup, T_CLASS, T_MODULE, T_OBJECT, and val.
Definition at line 432 of file variable.c.
References rb_path_to_class(), and rb_str_new_cstr().
Referenced by Init_md5(), Init_ossl_digest(), Init_rmd160(), and Init_sha1().
Definition at line 390 of file variable.c.
References id, fc_result::path, PRIsVALUE, QUOTE, rb_check_id_cstr(), rb_cObject, rb_eArgError, rb_enc_asciicompat, rb_enc_get(), rb_raise(), rb_str_subseq(), RSTRING_LEN, and RSTRING_PTR.
Referenced by rb_path2class().
Definition at line 2555 of file variable.c.
Definition at line 2561 of file variable.c.
Definition at line 2549 of file variable.c.
Definition at line 2310 of file variable.c.
Definition at line 2316 of file variable.c.
Definition at line 2304 of file variable.c.
Definition at line 337 of file variable.c.
Referenced by rb_vm_bugreport().
Definition at line 367 of file variable.c.
Definition at line 344 of file variable.c.
Referenced by rb_define_class_id_under(), and rb_define_module_id_under().
Definition at line 3120 of file variable.c.
References st_copy, and st_foreach.
struct rb_id_table* rb_global_tbl |
Definition at line 24 of file variable.c.