Ruby  2.1.10p492(2016-04-01revision54464)
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 "id.h"

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)
 
VALUE rb_class_path_cached (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, VALUE undef)
 
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 rb_ivar_lookup (VALUE obj, ID id, VALUE undef)
 
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)
 
static int rb_local_constants_i (st_data_t const_name, st_data_t const_value, st_data_t ary)
 
static VALUE rb_local_constants (VALUE mod)
 
voidrb_mod_const_at (VALUE mod, void *data)
 
voidrb_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 voidmod_cvar_at (VALUE mod, void *data)
 
static voidmod_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)
 
int rb_st_insert_id_and_value (VALUE obj, st_table *tbl, ID key, VALUE value)
 
static int tbl_copy_i (st_data_t key, st_data_t value, st_data_t data)
 
st_tablerb_st_copy (VALUE obj, struct st_table *orig_tbl)
 

Variables

st_tablerb_global_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 1552 of file variable.c.

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

#define CVAR_FOREACH_ANCESTORS (   klass,
  v,
  r 
)
Value:
if (cvar_lookup_at(klass, id, (v))) { \
r; \
} \
}
static int cvar_lookup_at(VALUE klass, ID id, st_data_t *v)
Definition: variable.c:2320
static VALUE cvar_front_klass(VALUE klass)
Definition: variable.c:2327
r
Definition: bigdecimal.c:1212
if(args--[1]==0)
Definition: array.c:3187
#define RCLASS_SUPER(c)
VALUE v
Definition: enum.c:845
klass
Definition: tcltklib.c:3496

Definition at line 2338 of file variable.c.

#define CVAR_LOOKUP (   v,
  r 
)
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:2320
r
Definition: bigdecimal.c:1212
if(args--[1]==0)
Definition: array.c:3187
VALUE v
Definition: enum.c:845
klass
Definition: tcltklib.c:3496
#define CVAR_FOREACH_ANCESTORS(klass, v, r)
Definition: variable.c:2338

Definition at line 2345 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 411 of file variable.c.

#define gvar_getter_t   rb_gvar_getter_t

Definition at line 414 of file variable.c.

Referenced by rb_define_hooked_variable().

#define gvar_marker_t   rb_gvar_marker_t

Definition at line 416 of file variable.c.

#define gvar_setter_t   rb_gvar_setter_t

Definition at line 415 of file variable.c.

Referenced by rb_define_hooked_variable().

#define readonly_setter   rb_gvar_readonly_setter

Definition at line 447 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 435 of file variable.c.

Referenced by rb_global_entry(), and rb_gvar_defined().

#define undef_marker   rb_gvar_undef_marker

Definition at line 437 of file variable.c.

Referenced by rb_global_entry().

#define undef_setter   rb_gvar_undef_setter

Definition at line 436 of file variable.c.

Referenced by rb_global_entry().

#define val_getter   rb_gvar_val_getter

Definition at line 439 of file variable.c.

Referenced by rb_define_virtual_variable(), and undef_setter().

#define val_marker   rb_gvar_val_marker

Definition at line 441 of file variable.c.

Referenced by undef_setter().

#define val_setter   rb_gvar_val_setter

Definition at line 440 of file variable.c.

Referenced by undef_setter().

#define var_getter   rb_gvar_var_getter

Definition at line 443 of file variable.c.

Referenced by rb_define_hooked_variable().

#define var_marker   rb_gvar_var_marker

Definition at line 445 of file variable.c.

Referenced by rb_define_hooked_variable().

#define var_setter   rb_gvar_var_setter

Definition at line 444 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 215 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 1735 of file variable.c.

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

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 1534 of file variable.c.

References st_free_table().

static void autoload_i_free ( void ptr)
static

Definition at line 1585 of file variable.c.

References p, ptr, and xfree.

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

Definition at line 1592 of file variable.c.

static void autoload_mark ( void ptr)
static

Definition at line 1528 of file variable.c.

References rb_mark_tbl().

static size_t autoload_memsize ( const void ptr)
static

Definition at line 1540 of file variable.c.

References ptr, st_memsize(), and tbl.

static VALUE autoload_provided ( VALUE  arg)
static

Definition at line 1672 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 1762 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 2157 of file variable.c.

References rb_check_frozen.

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 157 of file variable.c.

References classid, classpath, find_class_path(), n, NIL_P(), path, Qnil, rb_bug(), rb_cObject, rb_id2str(), RB_TYPE_P, RCLASS_IV_TBL, st_data_t, 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 1476 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 2450 of file variable.c.

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

Referenced by mod_cvar_at().

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

Definition at line 2489 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 2327 of file variable.c.

References FL_SINGLETON, FL_TEST, obj, rb_ivar_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 2320 of file variable.c.

References RCLASS_IV_TBL, st_data_t, 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 123 of file variable.c.

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

Referenced by classname().

static VALUE generic_ivar_defined ( VALUE  obj,
ID  id 
)
static

Definition at line 958 of file variable.c.

References data, Qfalse, Qtrue, st_data_t, st_lookup(), and tbl.

Referenced by rb_ivar_defined().

static VALUE generic_ivar_get ( VALUE  obj,
ID  id,
VALUE  undef 
)
static

Definition at line 918 of file variable.c.

References st_data_t, st_lookup(), tbl, and val.

Referenced by rb_ivar_lookup().

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 1011 of file variable.c.

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

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 1003 of file variable.c.

References rb_gc_mark(), ST_CONTINUE, and value.

Referenced by givar_i().

static ID global_id ( const char *  name)
static

Definition at line 569 of file variable.c.

References ALLOCA_N, buf, id, len, memcpy(), 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 835 of file variable.c.

References ary, 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 int ivar_i ( st_data_t  k,
st_data_t  v,
st_data_t  a 
)
static

Definition at line 1342 of file variable.c.

References ary, 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 2030 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 2464 of file variable.c.

References cv_i(), data, RCLASS_IV_TBL, st_data_t, st_foreach_safe(), st_init_numtable(), and tbl.

Referenced by mod_cvar_of(), and rb_mod_class_variables().

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

Definition at line 2477 of file variable.c.

References data, mod, mod_cvar_at(), RCLASS_SUPER, and tmp.

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 266 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 2312 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_cached ( VALUE  klass)

Definition at line 281 of file variable.c.

References classpath, n, Qnil, RCLASS_IV_TBL, st_data_t, st_lookup(), and tmp_classpath.

Referenced by newobj_i().

VALUE rb_class_path_no_cache ( VALUE  klass)

Definition at line 272 of file variable.c.

References NIL_P(), null_cache(), 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 2121 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 1874 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 2429 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 2419 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 2411 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 2439 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 610 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 604 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 853 of file variable.c.

References ary, 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 1030 of file variable.c.

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

Referenced by obj_free(), and rb_copy_generic_ivar().

void rb_gc_mark_global_tbl ( void  )

Definition at line 562 of file variable.c.

References mark_global_entry(), and st_foreach_safe().

Referenced by gc_mark_roots().

RUBY_FUNC_EXPORTED size_t rb_generic_ivar_memsize ( VALUE  obj)

Definition at line 1040 of file variable.c.

References st_data_t, st_lookup(), st_memsize(), and tbl.

Referenced by obj_memsize_of().

st_table* rb_generic_ivar_table ( VALUE  obj)

Definition at line 907 of file variable.c.

References FL_EXIVAR, FL_TEST, st_data_t, st_lookup(), and tbl.

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

Definition at line 819 of file variable.c.

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

Referenced by load_file(), and mSyslog_open().

VALUE rb_gv_set ( const char *  name,
VALUE  val 
)

Definition at line 810 of file variable.c.

References entry, 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 828 of file variable.c.

References Qfalse, Qtrue, and undef_getter.

VALUE rb_gvar_get ( struct global_entry entry)

Definition at line 760 of file variable.c.

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

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 
)
static VALUE rb_ivar_lookup ( VALUE  obj,
ID  id,
VALUE  undef 
)
static
VALUE rb_ivar_set ( VALUE  obj,
ID  id,
VALUE  val 
)
static VALUE rb_local_constants ( VALUE  mod)
static
static int rb_local_constants_i ( st_data_t  const_name,
st_data_t  const_value,
st_data_t  ary 
)
static

Definition at line 1984 of file variable.c.

References ID2SYM, rb_ary_push(), and ST_CONTINUE.

Referenced by rb_local_constants().

void rb_mark_generic_ivar ( VALUE  obj)

Definition at line 992 of file variable.c.

References rb_mark_tbl(), st_data_t, st_lookup(), and tbl.

Referenced by gc_mark_children().

void rb_mark_generic_ivar_tbl ( void  )

Definition at line 1022 of file variable.c.

References givar_i(), and st_foreach_safe().

Referenced by gc_mark_roots().

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

Definition at line 2531 of file variable.c.

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

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 1519 of file variable.c.

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

Referenced by Init_Object().

void* rb_mod_const_of ( VALUE  mod,
void data 
)

Definition at line 2017 of file variable.c.

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

Referenced by rb_mod_constants(), and rb_mod_s_constants().

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

Definition at line 206 of file variable.c.

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

Referenced by Init_Object().

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

Definition at line 2291 of file variable.c.

References CONST_PRIVATE, obj, and set_const_visibility().

Referenced by Init_Object().

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

Definition at line 2305 of file variable.c.

References CONST_PUBLIC, obj, 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 385 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 1371 of file variable.c.

References ary, 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 2145 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 2151 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 2139 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 1898 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 1904 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 1892 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 
)
st_table* rb_st_copy ( VALUE  obj,
struct st_table orig_tbl 
)
int rb_st_insert_id_and_value ( VALUE  obj,
st_table tbl,
ID  key,
VALUE  value 
)
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 627 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 540 of file variable.c.

References PRIsVALUE, QUOTE_ID, and rb_name_error().

static void remove_trace ( struct global_variable var)
static

Definition at line 683 of file variable.c.

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

Referenced by rb_f_untrace_var(), and trace_en().

static VALUE reset_safe ( VALUE  safe)
static

Definition at line 1679 of file variable.c.

References rb_set_safe_level_force(), and safe.

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 1969 of file variable.c.

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

Referenced by rb_mod_const_at().

static int tbl_copy_i ( st_data_t  key,
st_data_t  value,
st_data_t  data 
)
static

Definition at line 2629 of file variable.c.

References Qundef, RB_OBJ_WRITTEN, and ST_CONTINUE.

Referenced by rb_st_copy().

static VALUE trace_en ( struct global_variable var)
static

Definition at line 785 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 772 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 478 of file variable.c.

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

void undef_marker ( VALUE var)

Definition at line 496 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 1464 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 501 of file variable.c.

References data.

void val_marker ( VALUE var)

Definition at line 513 of file variable.c.

References data, and rb_gc_mark_maybe().

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

Definition at line 507 of file variable.c.

References global_variable::data.

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

Definition at line 520 of file variable.c.

References data, Qnil, and var.

void var_marker ( VALUE var)

Definition at line 534 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 528 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",
}
#define RUBY_TYPED_FREE_IMMEDIATELY
static void autoload_i_free(void *ptr)
Definition: variable.c:1585
static void autoload_i_mark(void *ptr)
Definition: variable.c:1576
static size_t autoload_i_memsize(const void *ptr)
Definition: variable.c:1592
#define NULL
Definition: _sdbm.c:102

Definition at line 1597 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:1534
#define RUBY_TYPED_FREE_IMMEDIATELY
static size_t autoload_memsize(const void *ptr)
Definition: variable.c:1540
#define NULL
Definition: _sdbm.c:102
static void autoload_mark(void *ptr)
Definition: variable.c:1528

Definition at line 1546 of file variable.c.

ID classid
static
ID classpath
static
st_table* generic_iv_tbl
static

Definition at line 904 of file variable.c.

st_table* rb_global_tbl

Definition at line 23 of file variable.c.

int special_generic_ivar = 0
static

Definition at line 903 of file variable.c.

ID tmp_classpath
static