Ruby  2.0.0p451(2014-02-24revision45167)
Data Structures | Macros | Typedefs | Functions | Variables
variable.c File Reference
#include "ruby/ruby.h"
#include "ruby/st.h"
#include "ruby/util.h"
#include "ruby/encoding.h"
#include "node.h"
#include "constant.h"
#include "internal.h"
Include dependency graph for variable.c:

Go to the source code of this file.

Data Structures

struct  fc_result
 
struct  trace_var
 
struct  global_variable
 
struct  trace_data
 
struct  obj_ivar_tag
 
struct  autoload_data_i
 
struct  autoload_const_set_args
 

Macros

#define global_variable   rb_global_variable
 
#define global_entry   rb_global_entry
 
#define gvar_getter_t   rb_gvar_getter_t
 
#define gvar_setter_t   rb_gvar_setter_t
 
#define gvar_marker_t   rb_gvar_marker_t
 
#define undef_getter   rb_gvar_undef_getter
 
#define undef_setter   rb_gvar_undef_setter
 
#define undef_marker   rb_gvar_undef_marker
 
#define val_getter   rb_gvar_val_getter
 
#define val_setter   rb_gvar_val_setter
 
#define val_marker   rb_gvar_val_marker
 
#define var_getter   rb_gvar_var_getter
 
#define var_setter   rb_gvar_var_setter
 
#define var_marker   rb_gvar_var_marker
 
#define readonly_setter   rb_gvar_readonly_setter
 
#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, ID id, VALUE val)
 

Functions

void Init_var_tables (void)
 
static VALUE fc_path (struct fc_result *fc, ID name)
 
static int fc_i (st_data_t k, st_data_t v, st_data_t a)
 
static VALUE find_class_path (VALUE klass, ID preferred)
 Traverse constant namespace and find +classpath+ for klass. More...
 
static VALUE classname (VALUE klass, int *permanent)
 Returns +classpath+ of klass, if it is named, or +nil+ for anonymous +class+/+module+. More...
 
VALUE rb_mod_name (VALUE mod)
 
static VALUE rb_tmp_class_path (VALUE klass, int *permanent, path_cache_func cache_path)
 
VALUE rb_class_path (VALUE klass)
 
static VALUE null_cache (VALUE obj, ID id, VALUE val)
 
VALUE rb_class_path_no_cache (VALUE klass)
 
void rb_set_class_path_string (VALUE klass, VALUE under, VALUE name)
 
void rb_set_class_path (VALUE klass, VALUE under, const char *name)
 
VALUE rb_path_to_class (VALUE pathname)
 
VALUE rb_path2class (const char *path)
 
void rb_name_class (VALUE klass, ID id)
 
VALUE rb_class_name (VALUE klass)
 
const char * rb_class2name (VALUE klass)
 
const char * rb_obj_classname (VALUE obj)
 
struct global_entryrb_global_entry (ID id)
 
VALUE undef_getter (ID id, void *data, struct global_variable *var)
 
void undef_setter (VALUE val, ID id, void *data, struct global_variable *var)
 
void undef_marker (VALUE *var)
 
VALUE val_getter (ID id, void *data, struct global_variable *var)
 
void val_setter (VALUE val, ID id, void *data, struct global_variable *var)
 
void val_marker (VALUE *var)
 
VALUE var_getter (ID id, void *data, struct global_variable *gvar)
 
void var_setter (VALUE val, ID id, void *data, struct global_variable *gvar)
 
void var_marker (VALUE *var)
 
void readonly_setter (VALUE val, ID id, void *data, struct global_variable *gvar)
 
static int mark_global_entry (st_data_t k, st_data_t v, st_data_t a)
 
void rb_gc_mark_global_tbl (void)
 
static ID global_id (const char *name)
 
void rb_define_hooked_variable (const char *name, VALUE *var, VALUE(*getter)(ANYARGS), void(*setter)(ANYARGS))
 
void rb_define_variable (const char *name, VALUE *var)
 
void rb_define_readonly_variable (const char *name, VALUE *var)
 
void rb_define_virtual_variable (const char *name, VALUE(*getter)(ANYARGS), void(*setter)(ANYARGS))
 
static void rb_trace_eval (VALUE cmd, VALUE val)
 
VALUE rb_f_trace_var (int argc, VALUE *argv)
 
static void remove_trace (struct global_variable *var)
 
VALUE rb_f_untrace_var (int argc, VALUE *argv)
 
VALUE rb_gvar_get (struct global_entry *entry)
 
static VALUE trace_ev (struct trace_data *data)
 
static VALUE trace_en (struct global_variable *var)
 
VALUE rb_gvar_set (struct global_entry *entry, VALUE val)
 
VALUE rb_gv_set (const char *name, VALUE val)
 
VALUE rb_gv_get (const char *name)
 
VALUE rb_gvar_defined (struct global_entry *entry)
 
static int gvar_i (st_data_t k, st_data_t v, st_data_t a)
 
VALUE rb_f_global_variables (void)
 
void rb_alias_variable (ID name1, ID name2)
 
st_tablerb_generic_ivar_table (VALUE obj)
 
static VALUE generic_ivar_get (VALUE obj, ID id, int warn)
 
static void generic_ivar_set (VALUE obj, ID id, VALUE val)
 
static VALUE generic_ivar_defined (VALUE obj, ID id)
 
static int generic_ivar_remove (VALUE obj, ID id, st_data_t *valp)
 
void rb_mark_generic_ivar (VALUE obj)
 
static int givar_mark_i (st_data_t k, st_data_t v, st_data_t a)
 
static int givar_i (st_data_t k, st_data_t v, st_data_t a)
 
void rb_mark_generic_ivar_tbl (void)
 
void rb_free_generic_ivar (VALUE obj)
 
RUBY_FUNC_EXPORTED size_t rb_generic_ivar_memsize (VALUE obj)
 
void rb_copy_generic_ivar (VALUE clone, VALUE obj)
 
static VALUE ivar_get (VALUE obj, ID id, int warn)
 
VALUE rb_ivar_get (VALUE obj, ID id)
 
VALUE rb_attr_get (VALUE obj, ID id)
 
VALUE rb_ivar_set (VALUE obj, ID id, VALUE val)
 
VALUE rb_ivar_defined (VALUE obj, ID id)
 
static int obj_ivar_i (st_data_t key, st_data_t index, st_data_t arg)
 
static void obj_ivar_each (VALUE obj, int(*func)(ANYARGS), st_data_t arg)
 
void rb_ivar_foreach (VALUE obj, int(*func)(ANYARGS), st_data_t arg)
 
st_index_t rb_ivar_count (VALUE obj)
 
static int ivar_i (st_data_t k, st_data_t v, st_data_t a)
 
VALUE rb_obj_instance_variables (VALUE obj)
 
VALUE rb_obj_remove_instance_variable (VALUE obj, VALUE name)
 
 NORETURN (static void uninitialized_constant(VALUE, ID))
 
static void uninitialized_constant (VALUE klass, ID id)
 
static VALUE const_missing (VALUE klass, ID id)
 
VALUE rb_mod_const_missing (VALUE klass, VALUE name)
 
static void autoload_mark (void *ptr)
 
static void autoload_free (void *ptr)
 
static size_t autoload_memsize (const void *ptr)
 
static VALUE autoload_data (VALUE mod, ID id)
 
static void autoload_i_mark (void *ptr)
 
static void autoload_i_free (void *ptr)
 
static size_t autoload_i_memsize (const void *ptr)
 
void rb_autoload (VALUE mod, ID id, const char *file)
 
static void autoload_delete (VALUE mod, ID id)
 
static VALUE autoload_provided (VALUE arg)
 
static VALUE reset_safe (VALUE safe)
 
static VALUE check_autoload_required (VALUE mod, ID id, const char **loadingpath)
 
int rb_autoloading_value (VALUE mod, ID id, VALUE *value)
 
static int autoload_defined_p (VALUE mod, ID id)
 
static VALUE autoload_const_set (VALUE arg)
 
static VALUE autoload_require (VALUE arg)
 
VALUE rb_autoload_load (VALUE mod, ID id)
 
VALUE rb_autoload_p (VALUE mod, ID id)
 
static VALUE rb_const_get_0 (VALUE klass, ID id, int exclude, int recurse, int visibility)
 
VALUE rb_const_get_from (VALUE klass, ID id)
 
VALUE rb_const_get (VALUE klass, ID id)
 
VALUE rb_const_get_at (VALUE klass, ID id)
 
VALUE rb_public_const_get_from (VALUE klass, ID id)
 
VALUE rb_public_const_get (VALUE klass, ID id)
 
VALUE rb_public_const_get_at (VALUE klass, ID id)
 
VALUE rb_mod_remove_const (VALUE mod, VALUE name)
 
VALUE rb_const_remove (VALUE mod, ID id)
 
static int sv_i (st_data_t k, st_data_t v, st_data_t a)
 
void * rb_mod_const_at (VALUE mod, void *data)
 
void * rb_mod_const_of (VALUE mod, void *data)
 
static int list_i (st_data_t key, st_data_t value, VALUE ary)
 
VALUE rb_const_list (void *data)
 
VALUE rb_mod_constants (int argc, VALUE *argv, VALUE mod)
 
static int rb_const_defined_0 (VALUE klass, ID id, int exclude, int recurse, int visibility)
 
int rb_const_defined_from (VALUE klass, ID id)
 
int rb_const_defined (VALUE klass, ID id)
 
int rb_const_defined_at (VALUE klass, ID id)
 
int rb_public_const_defined_from (VALUE klass, ID id)
 
int rb_public_const_defined (VALUE klass, ID id)
 
int rb_public_const_defined_at (VALUE klass, ID id)
 
static void check_before_mod_set (VALUE klass, ID id, VALUE val, const char *dest)
 
void rb_const_set (VALUE klass, ID id, VALUE val)
 
void rb_define_const (VALUE klass, const char *name, VALUE val)
 
void rb_define_global_const (const char *name, VALUE val)
 
static void set_const_visibility (VALUE mod, int argc, VALUE *argv, rb_const_flag_t flag)
 
VALUE rb_mod_private_constant (int argc, VALUE *argv, VALUE obj)
 
VALUE rb_mod_public_constant (int argc, VALUE *argv, VALUE obj)
 
static VALUE original_module (VALUE c)
 
static int cvar_lookup_at (VALUE klass, ID id, st_data_t *v)
 
static VALUE cvar_front_klass (VALUE klass)
 
void rb_cvar_set (VALUE klass, ID id, VALUE val)
 
VALUE rb_cvar_get (VALUE klass, ID id)
 
VALUE rb_cvar_defined (VALUE klass, ID id)
 
void rb_cv_set (VALUE klass, const char *name, VALUE val)
 
VALUE rb_cv_get (VALUE klass, const char *name)
 
void rb_define_class_variable (VALUE klass, const char *name, VALUE val)
 
static int cv_i (st_data_t k, st_data_t v, st_data_t a)
 
static void * mod_cvar_at (VALUE mod, void *data)
 
static void * mod_cvar_of (VALUE mod, void *data)
 
static int cv_list_i (st_data_t key, st_data_t value, VALUE ary)
 
static VALUE cvar_list (void *data)
 
VALUE rb_mod_class_variables (int argc, VALUE *argv, VALUE mod)
 
VALUE rb_mod_remove_cvar (VALUE mod, VALUE name)
 
VALUE rb_iv_get (VALUE obj, const char *name)
 
VALUE rb_iv_set (VALUE obj, const char *name, VALUE val)
 

Variables

st_tablerb_global_tbl
 
st_tablerb_class_tbl
 
static ID autoload
 
static ID classpath
 
static ID tmp_classpath
 
static ID classid
 
static int special_generic_ivar = 0
 
static st_tablegeneric_iv_tbl
 
static const rb_data_type_t autoload_data_type
 
static const rb_data_type_t autoload_data_i_type
 

Macro Definition Documentation

#define check_autoload_data (   av)    (struct autoload_data_i *)rb_check_typeddata((av), &autoload_data_i_type)
#define check_autoload_table (   av)    (struct st_table *)rb_check_typeddata((av), &autoload_data_type)

Definition at line 1550 of file variable.c.

Referenced by autoload_data(), autoload_delete(), and rb_autoload().

#define CVAR_FOREACH_ANCESTORS (   klass,
  v,
 
)
Value:
for (klass = cvar_front_klass(klass); klass; klass = RCLASS_SUPER(klass)) { \
if (cvar_lookup_at(klass, id, (v))) { \
r; \
} \
}
static int cvar_lookup_at(VALUE klass, ID id, st_data_t *v)
Definition: variable.c:2298
static VALUE cvar_front_klass(VALUE klass)
Definition: variable.c:2305
#define RCLASS_SUPER(c)
v
Definition: win32ole.c:798
if(c== ')') lex_state
Definition: ripper.y:7588

Definition at line 2316 of file variable.c.

#define CVAR_LOOKUP (   v,
 
)
Value:
do {\
if (cvar_lookup_at(klass, id, (v))) {r;}\
} while(0)
static int cvar_lookup_at(VALUE klass, ID id, st_data_t *v)
Definition: variable.c:2298
v
Definition: win32ole.c:798
#define CVAR_FOREACH_ANCESTORS(klass, v, r)
Definition: variable.c:2316
if(c== ')') lex_state
Definition: ripper.y:7588

Definition at line 2323 of file variable.c.

Referenced by rb_cvar_defined(), rb_cvar_get(), and rb_cvar_set().

#define global_entry   rb_global_entry

Definition at line 401 of file variable.c.

#define gvar_getter_t   rb_gvar_getter_t

Definition at line 404 of file variable.c.

Referenced by rb_define_hooked_variable().

#define gvar_marker_t   rb_gvar_marker_t

Definition at line 406 of file variable.c.

#define gvar_setter_t   rb_gvar_setter_t

Definition at line 405 of file variable.c.

Referenced by rb_define_hooked_variable().

#define readonly_setter   rb_gvar_readonly_setter

Definition at line 437 of file variable.c.

Referenced by rb_define_readonly_variable(), and rb_define_virtual_variable().

#define undef_getter   rb_gvar_undef_getter

Definition at line 425 of file variable.c.

Referenced by rb_global_entry(), and rb_gvar_defined().

#define undef_marker   rb_gvar_undef_marker

Definition at line 427 of file variable.c.

Referenced by rb_global_entry().

#define undef_setter   rb_gvar_undef_setter

Definition at line 426 of file variable.c.

Referenced by rb_global_entry().

#define val_getter   rb_gvar_val_getter

Definition at line 429 of file variable.c.

Referenced by rb_define_virtual_variable(), and undef_setter().

#define val_marker   rb_gvar_val_marker

Definition at line 431 of file variable.c.

Referenced by undef_setter().

#define val_setter   rb_gvar_val_setter

Definition at line 430 of file variable.c.

Referenced by undef_setter().

#define var_getter   rb_gvar_var_getter

Definition at line 433 of file variable.c.

Referenced by rb_define_hooked_variable().

#define var_marker   rb_gvar_var_marker

Definition at line 435 of file variable.c.

Referenced by rb_define_hooked_variable().

#define var_setter   rb_gvar_var_setter

Definition at line 434 of file variable.c.

Referenced by rb_define_hooked_variable().

Typedef Documentation

typedef VALUE(* path_cache_func)(VALUE obj, ID id, VALUE val)

Definition at line 219 of file variable.c.

Function Documentation

static VALUE autoload_const_set ( VALUE  arg)
static
static VALUE autoload_data ( VALUE  mod,
ID  id 
)
static
static int autoload_defined_p ( VALUE  mod,
ID  id 
)
static

Definition at line 1731 of file variable.c.

References NULL, Qundef, rb_autoloading_value(), RCLASS_CONST_TBL, st_lookup(), and val.

Referenced by rb_autoload_load(), and rb_autoload_p().

static void autoload_delete ( VALUE  mod,
ID  id 
)
static
static void autoload_free ( void *  ptr)
static

Definition at line 1533 of file variable.c.

References st_free_table().

static void autoload_i_free ( void *  ptr)
static

Definition at line 1583 of file variable.c.

References p, and xfree.

static void autoload_i_mark ( void *  ptr)
static
static size_t autoload_i_memsize ( const void *  ptr)
static

Definition at line 1590 of file variable.c.

static void autoload_mark ( void *  ptr)
static

Definition at line 1527 of file variable.c.

References rb_mark_tbl().

static size_t autoload_memsize ( const void *  ptr)
static

Definition at line 1539 of file variable.c.

References st_memsize().

static VALUE autoload_provided ( VALUE  arg)
static

Definition at line 1668 of file variable.c.

References p, and rb_feature_provided().

Referenced by check_autoload_required().

static VALUE autoload_require ( VALUE  arg)
static

Definition at line 1758 of file variable.c.

References autoload_data_i::feature, rb_require_safe(), and autoload_data_i::safe_level.

Referenced by rb_autoload_load().

static VALUE check_autoload_required ( VALUE  mod,
ID  id,
const char **  loadingpath 
)
static
static void check_before_mod_set ( VALUE  klass,
ID  id,
VALUE  val,
const char *  dest 
)
static

Definition at line 2133 of file variable.c.

References OBJ_UNTRUSTED, rb_check_frozen, rb_eSecurityError, rb_raise(), and rb_safe_level.

Referenced by rb_const_set(), and rb_cvar_set().

static VALUE classname ( VALUE  klass,
int *  permanent 
)
static

Returns +classpath+ of klass, if it is named, or +nil+ for anonymous +class+/+module+.

The last part of named +classpath+ is never anonymous, but anonymous +class+/+module+ names may be contained. If the path is "permanent", that means it has no anonymous names, *permanent is set to 1.

Definition at line 160 of file variable.c.

References classid, classpath, find_class_path(), NIL_P, OBJ_FREEZE, fc_result::path, Qnil, rb_bug(), rb_cObject, rb_id2str(), rb_str_dup(), RB_TYPE_P, RCLASS_IV_TBL, st_lookup(), SYM2ID, T_STRING, and tmp_classpath.

Referenced by rb_cmperr(), rb_mod_name(), and rb_tmp_class_path().

static VALUE const_missing ( VALUE  klass,
ID  id 
)
static

Definition at line 1475 of file variable.c.

References ID2SYM, rb_funcall(), and rb_intern.

Referenced by rb_const_get_0().

static int cv_i ( st_data_t  k,
st_data_t  v,
st_data_t  a 
)
static

Definition at line 2428 of file variable.c.

References key, rb_is_class_id(), ST_CONTINUE, st_insert(), and st_lookup().

Referenced by mod_cvar_at().

static int cv_list_i ( st_data_t  key,
st_data_t  value,
VALUE  ary 
)
static

Definition at line 2467 of file variable.c.

References ID2SYM, rb_ary_push(), ST_CONTINUE, and sym.

Referenced by cvar_list().

static VALUE cvar_front_klass ( VALUE  klass)
static

Definition at line 2305 of file variable.c.

References FL_SINGLETON, FL_TEST, rb_iv_get(), RB_TYPE_P, RCLASS_SUPER, T_CLASS, and T_MODULE.

static VALUE cvar_list ( void *  data)
static
static int cvar_lookup_at ( VALUE  klass,
ID  id,
st_data_t v 
)
static

Definition at line 2298 of file variable.c.

References RCLASS_IV_TBL, and st_lookup().

static int fc_i ( st_data_t  k,
st_data_t  v,
st_data_t  a 
)
static
static VALUE fc_path ( struct fc_result fc,
ID  name 
)
static
static VALUE find_class_path ( VALUE  klass,
ID  preferred 
)
static

Traverse constant namespace and find +classpath+ for klass.

If preferred is not 0, choice the path whose base name is set to it. If +classpath+ is found, the hidden instance variable classpath is set to the found path, and tmp_classpath is removed. The path is frozen.

Definition at line 124 of file variable.c.

References classpath, fc_i(), fc_result::klass, fc_result::name, fc_result::path, fc_result::preferred, fc_result::prev, Qnil, rb_cObject, RCLASS_CONST_TBL, RCLASS_IV_TBL, st_delete(), st_foreach_safe(), st_init_numtable(), st_insert(), tmp_classpath, and fc_result::track.

Referenced by classname().

static VALUE generic_ivar_defined ( VALUE  obj,
ID  id 
)
static

Definition at line 956 of file variable.c.

References trace_var::data, Qfalse, Qtrue, and st_lookup().

Referenced by rb_ivar_defined().

static VALUE generic_ivar_get ( VALUE  obj,
ID  id,
int  warn 
)
static

Definition at line 915 of file variable.c.

References PRIsVALUE, Qnil, QUOTE_ID, rb_warning(), st_lookup(), and val.

Referenced by ivar_get().

static int generic_ivar_remove ( VALUE  obj,
ID  id,
st_data_t valp 
)
static
static void generic_ivar_set ( VALUE  obj,
ID  id,
VALUE  val 
)
static
static int givar_i ( st_data_t  k,
st_data_t  v,
st_data_t  a 
)
static

Definition at line 1009 of file variable.c.

References givar_mark_i(), rb_special_const_p(), ST_CONTINUE, and st_foreach_safe().

Referenced by rb_mark_generic_ivar_tbl().

static int givar_mark_i ( st_data_t  k,
st_data_t  v,
st_data_t  a 
)
static

Definition at line 1001 of file variable.c.

References rb_gc_mark(), and ST_CONTINUE.

Referenced by givar_i().

static ID global_id ( const char *  name)
static

Definition at line 559 of file variable.c.

References ALLOCA_N, buf, id, rb_intern, rb_intern2(), and strlen().

Referenced by rb_define_hooked_variable(), rb_gv_get(), and rb_gv_set().

static int gvar_i ( st_data_t  k,
st_data_t  v,
st_data_t  a 
)
static

Definition at line 829 of file variable.c.

References ID2SYM, key, rb_ary_push(), and ST_CONTINUE.

Referenced by rb_f_global_variables().

void Init_var_tables ( void  )

Definition at line 27 of file variable.c.

References autoload, classid, classpath, CONST_ID, st_init_numtable(), and tmp_classpath.

static VALUE ivar_get ( VALUE  obj,
ID  id,
int  warn 
)
static
static int ivar_i ( st_data_t  k,
st_data_t  v,
st_data_t  a 
)
static

Definition at line 1339 of file variable.c.

References ID2SYM, key, rb_ary_push(), rb_is_instance_id(), and ST_CONTINUE.

Referenced by rb_obj_instance_variables().

static int list_i ( st_data_t  key,
st_data_t  value,
VALUE  ary 
)
static

Definition at line 2008 of file variable.c.

References CONST_PRIVATE, rb_const_entry_struct::flag, ID2SYM, rb_ary_push(), ST_CONTINUE, and sym.

Referenced by rb_const_list().

static int mark_global_entry ( st_data_t  k,
st_data_t  v,
st_data_t  a 
)
static
static void* mod_cvar_at ( VALUE  mod,
void *  data 
)
static

Definition at line 2442 of file variable.c.

References cv_i(), RCLASS_IV_TBL, st_foreach_safe(), and st_init_numtable().

Referenced by mod_cvar_of(), and rb_mod_class_variables().

static void* mod_cvar_of ( VALUE  mod,
void *  data 
)
static

Definition at line 2455 of file variable.c.

References mod, mod_cvar_at(), and RCLASS_SUPER.

Referenced by rb_mod_class_variables().

NORETURN ( static void   uninitialized_constantVALUE, ID)
static VALUE null_cache ( VALUE  obj,
ID  id,
VALUE  val 
)
static

Definition at line 270 of file variable.c.

References Qnil.

Referenced by rb_class_path_no_cache().

static void obj_ivar_each ( VALUE  obj,
int(*)(ANYARGS func,
st_data_t  arg 
)
static
static int obj_ivar_i ( st_data_t  key,
st_data_t  index,
st_data_t  arg 
)
static
static VALUE original_module ( VALUE  c)
static

Definition at line 2290 of file variable.c.

References c, RB_TYPE_P, RBASIC, and T_ICLASS.

Referenced by rb_cvar_get(), and rb_cvar_set().

void rb_alias_variable ( ID  name1,
ID  name2 
)
VALUE rb_attr_get ( VALUE  obj,
ID  id 
)
void rb_autoload ( VALUE  mod,
ID  id,
const char *  file 
)
VALUE rb_autoload_load ( VALUE  mod,
ID  id 
)
VALUE rb_autoload_p ( VALUE  mod,
ID  id 
)
int rb_autoloading_value ( VALUE  mod,
ID  id,
VALUE value 
)
const char* rb_class2name ( VALUE  klass)
VALUE rb_class_name ( VALUE  klass)
VALUE rb_class_path ( VALUE  klass)
VALUE rb_class_path_no_cache ( VALUE  klass)

Definition at line 276 of file variable.c.

References NIL_P, null_cache(), fc_result::path, rb_str_dup(), and rb_tmp_class_path().

int rb_const_defined ( VALUE  klass,
ID  id 
)
static int rb_const_defined_0 ( VALUE  klass,
ID  id,
int  exclude,
int  recurse,
int  visibility 
)
static
int rb_const_defined_at ( VALUE  klass,
ID  id 
)
int rb_const_defined_from ( VALUE  klass,
ID  id 
)

Definition at line 2097 of file variable.c.

References FALSE, rb_const_defined_0(), and TRUE.

VALUE rb_const_get ( VALUE  klass,
ID  id 
)
static VALUE rb_const_get_0 ( VALUE  klass,
ID  id,
int  exclude,
int  recurse,
int  visibility 
)
static
VALUE rb_const_get_at ( VALUE  klass,
ID  id 
)
VALUE rb_const_get_from ( VALUE  klass,
ID  id 
)

Definition at line 1870 of file variable.c.

References FALSE, rb_const_get_0(), and TRUE.

VALUE rb_const_list ( void *  data)
VALUE rb_const_remove ( VALUE  mod,
ID  id 
)
void rb_const_set ( VALUE  klass,
ID  id,
VALUE  val 
)
void rb_copy_generic_ivar ( VALUE  clone,
VALUE  obj 
)
VALUE rb_cv_get ( VALUE  klass,
const char *  name 
)

Definition at line 2407 of file variable.c.

References rb_cvar_get(), rb_intern, rb_is_class_id(), and rb_name_error().

void rb_cv_set ( VALUE  klass,
const char *  name,
VALUE  val 
)

Definition at line 2397 of file variable.c.

References rb_cvar_set(), rb_intern, rb_is_class_id(), and rb_name_error().

VALUE rb_cvar_defined ( VALUE  klass,
ID  id 
)

Definition at line 2389 of file variable.c.

References CVAR_LOOKUP, Qfalse, and Qtrue.

Referenced by rb_mod_cvar_defined(), and rb_mod_remove_cvar().

VALUE rb_cvar_get ( VALUE  klass,
ID  id 
)
void rb_cvar_set ( VALUE  klass,
ID  id,
VALUE  val 
)
void rb_define_class_variable ( VALUE  klass,
const char *  name,
VALUE  val 
)

Definition at line 2417 of file variable.c.

References rb_cvar_set(), rb_intern, rb_is_class_id(), and rb_name_error().

void rb_define_const ( VALUE  klass,
const char *  name,
VALUE  val 
)
void rb_define_global_const ( const char *  name,
VALUE  val 
)
void rb_define_hooked_variable ( const char *  name,
VALUE var,
VALUE(*)(ANYARGS getter,
void(*)(ANYARGS setter 
)
void rb_define_readonly_variable ( const char *  name,
VALUE var 
)

Definition at line 600 of file variable.c.

References rb_define_hooked_variable(), and readonly_setter.

Referenced by Init_IO().

void rb_define_variable ( const char *  name,
VALUE var 
)

Definition at line 594 of file variable.c.

References rb_define_hooked_variable().

Referenced by Init_IO(), Init_String(), and ruby_prog_init().

void rb_define_virtual_variable ( const char *  name,
VALUE(*)(ANYARGS getter,
void(*)(ANYARGS setter 
)
VALUE rb_f_global_variables ( void  )

Definition at line 847 of file variable.c.

References buf, gvar_i(), i, ID2SYM, rb_ary_new(), rb_ary_push(), rb_intern2(), and st_foreach_safe().

Referenced by Init_eval().

VALUE rb_f_trace_var ( int  argc,
VALUE argv 
)
VALUE rb_f_untrace_var ( int  argc,
VALUE argv 
)
void rb_free_generic_ivar ( VALUE  obj)

Definition at line 1028 of file variable.c.

References key, st_delete(), and st_free_table().

Referenced by obj_free(), and rb_copy_generic_ivar().

void rb_gc_mark_global_tbl ( void  )

Definition at line 552 of file variable.c.

References mark_global_entry(), and st_foreach_safe().

Referenced by gc_marks().

RUBY_FUNC_EXPORTED size_t rb_generic_ivar_memsize ( VALUE  obj)

Definition at line 1038 of file variable.c.

References st_lookup(), and st_memsize().

Referenced by memsize_of().

st_table* rb_generic_ivar_table ( VALUE  obj)

Definition at line 904 of file variable.c.

References FL_EXIVAR, FL_TEST, and st_lookup().

struct global_entry* rb_global_entry ( ID  id)
VALUE rb_gv_get ( const char *  name)

Definition at line 813 of file variable.c.

References global_entry, global_id(), rb_global_entry(), and rb_gvar_get().

Referenced by ip_ruby_cmd_receiver_get(), load_file(), and mSyslog_open().

VALUE rb_gv_set ( const char *  name,
VALUE  val 
)

Definition at line 804 of file variable.c.

References global_entry, global_id(), rb_global_entry(), and rb_gvar_set().

Referenced by process_sflag(), and restore_lineno().

VALUE rb_gvar_defined ( struct global_entry entry)

Definition at line 822 of file variable.c.

References Qfalse, Qtrue, and undef_getter.

VALUE rb_gvar_get ( struct global_entry entry)

Definition at line 752 of file variable.c.

References global_variable::data, and global_variable::getter.

Referenced by rb_gv_get().

VALUE rb_gvar_set ( struct global_entry entry,
VALUE  val 
)
VALUE rb_iv_get ( VALUE  obj,
const char *  name 
)
VALUE rb_iv_set ( VALUE  obj,
const char *  name,
VALUE  val 
)
st_index_t rb_ivar_count ( VALUE  obj)
VALUE rb_ivar_defined ( VALUE  obj,
ID  id 
)
void rb_ivar_foreach ( VALUE  obj,
int(*)(ANYARGS func,
st_data_t  arg 
)
VALUE rb_ivar_get ( VALUE  obj,
ID  id 
)
VALUE rb_ivar_set ( VALUE  obj,
ID  id,
VALUE  val 
)

Definition at line 1128 of file variable.c.

References ALLOC_N, st_table::as, BUILTIN_TYPE, generic_ivar_set(), i, MEMCPY, st_table::num_entries, OBJ_UNTRUSTED, Qundef, rb_check_frozen, rb_eSecurityError, rb_obj_class(), rb_raise(), rb_safe_level, RBASIC, RCLASS_IV_INDEX_TBL, RCLASS_IV_TBL, REALLOC_N, ROBJECT, ROBJECT_EMBED, ROBJECT_EMBED_LEN_MAX, ROBJECT_IV_INDEX_TBL, ROBJECT_IVPTR, ROBJECT_NUMIV, SPECIAL_CONST_P, st_add_direct(), st_init_numtable(), st_insert(), st_lookup(), T_CLASS, T_MODULE, T_OBJECT, and val.

Referenced by add_event_call_back(), ary2list(), ary2list2(), cbsubst_initialize(), create_encoding_table_core(), create_ip_exc(), cState_aset(), enc_set_index(), enum_chunk(), enum_slice_before(), enumerable_lazy(), eval_string_with_cref(), fev_initialize(), fev_set_handler(), gzfile_raise(), Init_md5(), Init_rmd160(), Init_sha1(), initialize_params(), int_ossl_asn1_decode0_prim(), lazy_drop_func(), lazy_drop_while_func(), lazy_initialize(), lazy_set_method(), lazy_take_func(), lazy_zip_arrays_func(), lazy_zip_func(), lib_fromUTF8_core(), lib_split_tklist_core(), lib_toUTF8_core(), lib_UTF_backslash_core(), make_econv_exception(), next_i(), nucomp_marshal_load(), nurat_marshal_load(), ole_method_params(), ole_variables(), olemethod_set_member(), oleparam_ole_param_from_index(), oletype_set_member(), ossl_sslctx_session_get_cb(), ossl_sslctx_session_new_cb(), ossl_start_ssl(), parse_main(), pipe_open(), r_ivar(), raise_loaderror(), range_dumper(), rb_class_path(), rb_inflate_s_allocate(), rb_io_init_copy(), rb_iv_set(), rb_mod_refine(), rb_name_class(), rb_obj_ivar_set(), rb_set_class_path(), rb_set_class_path_string(), rb_struct_define_without_accessor(), readline_s_set_completion_case_fold(), readline_s_set_completion_proc(), ruby_init_loadpath_safe(), set_strpath(), setup_struct(), sockopt_initialize(), time_mdump(), vm_call0_body(), and vm_setivar().

void rb_mark_generic_ivar ( VALUE  obj)

Definition at line 990 of file variable.c.

References rb_mark_tbl(), and st_lookup().

Referenced by gc_mark_children().

void rb_mark_generic_ivar_tbl ( void  )

Definition at line 1020 of file variable.c.

References givar_i(), and st_foreach_safe().

Referenced by gc_marks().

VALUE rb_mod_class_variables ( int  argc,
VALUE argv,
VALUE  mod 
)

Definition at line 2509 of file variable.c.

References cvar_list(), mod_cvar_at(), mod_cvar_of(), Qtrue, rb_scan_args(), and RTEST.

Referenced by Init_Object().

void* rb_mod_const_at ( VALUE  mod,
void *  data 
)
VALUE rb_mod_const_missing ( VALUE  klass,
VALUE  name 
)

Definition at line 1518 of file variable.c.

References rb_frame_pop(), rb_to_id(), uninitialized_constant(), and UNREACHABLE.

Referenced by Init_Object().

void* rb_mod_const_of ( VALUE  mod,
void *  data 
)

Definition at line 1995 of file variable.c.

References mod, rb_cObject, rb_mod_const_at(), and RCLASS_SUPER.

Referenced by rb_mod_constants(), and rb_mod_s_constants().

VALUE rb_mod_constants ( int  argc,
VALUE argv,
VALUE  mod 
)

Definition at line 2046 of file variable.c.

References Qtrue, rb_const_list(), rb_mod_const_at(), rb_mod_const_of(), rb_scan_args(), and RTEST.

Referenced by Init_Object(), and rb_mod_s_constants().

VALUE rb_mod_name ( VALUE  mod)

Definition at line 210 of file variable.c.

References classname(), NIL_P, fc_result::path, and rb_str_dup().

Referenced by Init_Object().

VALUE rb_mod_private_constant ( int  argc,
VALUE argv,
VALUE  obj 
)

Definition at line 2269 of file variable.c.

References CONST_PRIVATE, and set_const_visibility().

Referenced by Init_Object().

VALUE rb_mod_public_constant ( int  argc,
VALUE argv,
VALUE  obj 
)

Definition at line 2283 of file variable.c.

References CONST_PUBLIC, and set_const_visibility().

Referenced by Init_Object().

VALUE rb_mod_remove_const ( VALUE  mod,
VALUE  name 
)
VALUE rb_mod_remove_cvar ( VALUE  mod,
VALUE  name 
)
void rb_name_class ( VALUE  klass,
ID  id 
)

Definition at line 377 of file variable.c.

References classid, ID2SYM, and rb_ivar_set().

Referenced by boot_defclass(), rb_define_class(), and rb_define_module_id().

const char* rb_obj_classname ( VALUE  obj)
VALUE rb_obj_instance_variables ( VALUE  obj)

Definition at line 1368 of file variable.c.

References ivar_i(), rb_ary_new(), and rb_ivar_foreach().

VALUE rb_obj_remove_instance_variable ( VALUE  obj,
VALUE  name 
)
VALUE rb_path2class ( const char *  path)
VALUE rb_path_to_class ( VALUE  pathname)
int rb_public_const_defined ( VALUE  klass,
ID  id 
)

Definition at line 2121 of file variable.c.

References FALSE, rb_const_defined_0(), and TRUE.

int rb_public_const_defined_at ( VALUE  klass,
ID  id 
)

Definition at line 2127 of file variable.c.

References FALSE, rb_const_defined_0(), and TRUE.

int rb_public_const_defined_from ( VALUE  klass,
ID  id 
)

Definition at line 2115 of file variable.c.

References rb_const_defined_0(), and TRUE.

Referenced by vm_get_ev_const().

VALUE rb_public_const_get ( VALUE  klass,
ID  id 
)

Definition at line 1894 of file variable.c.

References FALSE, rb_const_get_0(), and TRUE.

VALUE rb_public_const_get_at ( VALUE  klass,
ID  id 
)

Definition at line 1900 of file variable.c.

References FALSE, rb_const_get_0(), and TRUE.

VALUE rb_public_const_get_from ( VALUE  klass,
ID  id 
)

Definition at line 1888 of file variable.c.

References rb_const_get_0(), and TRUE.

Referenced by vm_get_ev_const().

void rb_set_class_path ( VALUE  klass,
VALUE  under,
const char *  name 
)
void rb_set_class_path_string ( VALUE  klass,
VALUE  under,
VALUE  name 
)
static VALUE rb_tmp_class_path ( VALUE  klass,
int *  permanent,
path_cache_func  cache_path 
)
static
static void rb_trace_eval ( VALUE  cmd,
VALUE  val 
)
static

Definition at line 617 of file variable.c.

References rb_ary_new3(), and rb_eval_cmd().

Referenced by rb_f_trace_var().

void readonly_setter ( VALUE  val,
ID  id,
void *  data,
struct global_variable gvar 
)

Definition at line 530 of file variable.c.

References PRIsVALUE, QUOTE_ID, and rb_name_error().

static void remove_trace ( struct global_variable var)
static

Definition at line 674 of file variable.c.

References trace_var::next, trace_var::removed, global_variable::trace, and xfree.

Referenced by rb_f_untrace_var(), and trace_en().

static VALUE reset_safe ( VALUE  safe)
static

Definition at line 1675 of file variable.c.

References rb_set_safe_level_force().

Referenced by check_autoload_required(), and rb_autoload_load().

static void set_const_visibility ( VALUE  mod,
int  argc,
VALUE argv,
rb_const_flag_t  flag 
)
static
static int sv_i ( st_data_t  k,
st_data_t  v,
st_data_t  a 
)
static

Definition at line 1967 of file variable.c.

References key, rb_is_const_id(), ST_CONTINUE, st_insert(), and st_lookup().

Referenced by rb_mod_const_at().

static VALUE trace_en ( struct global_variable var)
static

Definition at line 777 of file variable.c.

References global_variable::block_trace, Qnil, and remove_trace().

Referenced by rb_gvar_set().

static VALUE trace_ev ( struct trace_data data)
static

Definition at line 764 of file variable.c.

References trace_var::data, trace_var::func, trace_var::next, Qnil, trace_data::trace, and trace_data::val.

Referenced by rb_gvar_set().

VALUE undef_getter ( ID  id,
void *  data,
struct global_variable var 
)

Definition at line 468 of file variable.c.

References PRIsVALUE, Qnil, QUOTE_ID, and rb_warning().

void undef_marker ( VALUE var)

Definition at line 486 of file variable.c.

void undef_setter ( VALUE  val,
ID  id,
void *  data,
struct global_variable var 
)
static void uninitialized_constant ( VALUE  klass,
ID  id 
)
static

Definition at line 1463 of file variable.c.

References PRIsVALUE, QUOTE_ID, rb_class_name(), rb_class_real(), rb_cObject, and rb_name_error().

Referenced by rb_mod_const_missing().

VALUE val_getter ( ID  id,
void *  data,
struct global_variable var 
)

Definition at line 491 of file variable.c.

void val_marker ( VALUE var)

Definition at line 503 of file variable.c.

References rb_gc_mark_maybe().

void val_setter ( VALUE  val,
ID  id,
void *  data,
struct global_variable var 
)

Definition at line 497 of file variable.c.

References global_variable::data.

VALUE var_getter ( ID  id,
void *  data,
struct global_variable gvar 
)

Definition at line 510 of file variable.c.

References Qnil.

void var_marker ( VALUE var)

Definition at line 524 of file variable.c.

References rb_gc_mark_maybe().

void var_setter ( VALUE  val,
ID  id,
void *  data,
struct global_variable gvar 
)

Definition at line 518 of file variable.c.

Variable Documentation

ID autoload
static

Definition at line 24 of file variable.c.

Referenced by autoload_data(), autoload_delete(), Init_var_tables(), and rb_autoload().

const rb_data_type_t autoload_data_i_type
static
Initial value:
= {
"autoload_i",
}
static void autoload_i_free(void *ptr)
Definition: variable.c:1583
static void autoload_i_mark(void *ptr)
Definition: variable.c:1574
static size_t autoload_i_memsize(const void *ptr)
Definition: variable.c:1590

Definition at line 1595 of file variable.c.

const rb_data_type_t autoload_data_type
static
Initial value:
= {
"autoload",
}
static void autoload_free(void *ptr)
Definition: variable.c:1533
static size_t autoload_memsize(const void *ptr)
Definition: variable.c:1539
static void autoload_mark(void *ptr)
Definition: variable.c:1527

Definition at line 1545 of file variable.c.

ID classid
static
ID classpath
static
st_table* generic_iv_tbl
static

Definition at line 901 of file variable.c.

st_table* rb_global_tbl

Definition at line 22 of file variable.c.

int special_generic_ivar = 0
static

Definition at line 900 of file variable.c.

ID tmp_classpath
static