Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals

variable.c File Reference

#include "ruby.h"
#include "env.h"
#include "node.h"
#include "st.h"
#include "util.h"

Go to the source code of this file.

Data Structures

struct  fc_result
struct  global_entry
struct  global_variable
struct  trace_data
struct  trace_var

Functions

void Init_var_tables ()
VALUE fc_path (struct fc_result *fc, ID name)
int fc_i (ID key, VALUE value, struct fc_result *res)
VALUE find_class_path (VALUE klass)
VALUE classname (VALUE klass)
VALUE rb_mod_name (VALUE mod)
VALUE rb_class_path (VALUE klass)
void rb_set_class_path (VALUE klass, VALUE under, const char *name)
VALUE rb_path2class (char *path) const
void rb_name_class (VALUE klass, ID id)
VALUE rb_class_name (VALUE klass)
char * rb_class2name (VALUE klass)
char * rb_obj_classname (VALUE obj)
VALUE undef_getter ()
void undef_setter ()
void undef_marker ()
VALUE val_getter ()
void val_setter ()
void val_marker ()
VALUE var_getter ()
void var_setter ()
void var_marker ()
global_entryrb_global_entry (ID id)
VALUE undef_getter (ID id)
void undef_setter (VALUE val, ID id, void *data, struct global_variable *var)
VALUE val_getter (ID id, VALUE val)
void val_setter (VALUE val, ID id, void *data, struct global_variable *var)
void val_marker (VALUE data)
VALUE var_getter (ID id, VALUE *var)
void var_setter (VALUE val, ID id, VALUE *var)
void var_marker (VALUE *var)
void readonly_setter (VALUE val, ID id, void *var)
int mark_global_entry (ID key, struct global_entry *entry)
void rb_gc_mark_global_tbl ()
ID global_id (char *name) const
void rb_define_hooked_variable (char *name, VALUE *var, getter, setter) const
void rb_define_variable (char *name, VALUE *var) const
void rb_define_readonly_variable (char *name, VALUE *var) const
void rb_define_virtual_variable (char *name, getter, setter) const
void rb_trace_eval (VALUE cmd, VALUE val)
VALUE rb_f_trace_var (int argc, VALUE *argv)
void remove_trace (struct global_variable *var)
VALUE rb_f_untrace_var (int argc, VALUE *argv)
VALUE rb_gvar_get (struct global_entry *entry)
VALUE trace_ev (struct trace_data *data)
VALUE trace_en (struct global_variable *var)
VALUE rb_gvar_set (struct global_entry *entry, VALUE val)
VALUE rb_gv_set (char *name, VALUE val) const
VALUE rb_gv_get (char *name) const
VALUE rb_gvar_defined (struct global_entry *entry)
int gvar_i (ID key, struct global_entry *entry, VALUE ary)
VALUE rb_f_global_variables ()
void rb_alias_variable (ID name1, ID name2)
st_tablerb_generic_ivar_table (VALUE obj)
VALUE generic_ivar_get (VALUE obj, ID id, int warn)
void generic_ivar_set (VALUE obj, ID id, VALUE val)
VALUE generic_ivar_defined (VALUE obj, ID id)
int generic_ivar_remove (VALUE obj, ID id, VALUE *valp)
void rb_mark_generic_ivar (VALUE obj)
int givar_mark_i (ID key, VALUE value)
int givar_i (VALUE obj, st_table *tbl)
void rb_mark_generic_ivar_tbl ()
void rb_free_generic_ivar (VALUE obj)
void rb_copy_generic_ivar (VALUE clone, VALUE obj)
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)
int ivar_i (ID key, struct global_entry *entry, VALUE ary)
VALUE rb_obj_instance_variables (VALUE obj)
VALUE rb_obj_remove_instance_variable (VALUE obj, VALUE name)
void uninitialized_constant (VALUE, ID)
VALUE const_missing (VALUE klass, ID id)
VALUE rb_mod_const_missing (VALUE klass, VALUE name)
st_tablecheck_autoload_table (VALUE av)
void rb_autoload (VALUE mod, ID id, const char *file)
NODEautoload_delete (VALUE mod, ID id)
VALUE rb_autoload_load (VALUE klass, ID id)
VALUE autoload_file (VALUE mod, ID id)
VALUE rb_autoload_p (VALUE mod, ID id)
VALUE rb_const_get_0 (VALUE klass, ID id, int exclude, int recurse)
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_mod_remove_const (VALUE mod, VALUE name)
int sv_i (ID key, VALUE value, st_table *tbl)
void * rb_mod_const_at (VALUE mod, void *data)
void * rb_mod_const_of (VALUE mod, void *data)
int list_i (ID key, ID value, VALUE ary)
VALUE rb_const_list (void *data)
VALUE rb_mod_constants (VALUE mod)
int rb_const_defined_0 (VALUE klass, ID id, int exclude, int recurse)
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)
void mod_av_set (VALUE klass, ID id, VALUE val, int isconst)
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 (char *name, VALUE val) const
VALUE original_module (VALUE c)
void cvar_override_check (ID id, VALUE a)
void rb_cvar_set (VALUE klass, ID id, VALUE val, int warn)
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)
int cv_i (ID key, VALUE value, VALUE ary)
VALUE rb_mod_class_variables (VALUE obj)
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
ID autoload
ID classpath
ID tmp_classpath
int special_generic_ivar = 0
st_tablegeneric_iv_tbl


Function Documentation

NODE* autoload_delete VALUE  mod,
ID  id
[static]
 

Definition at line 1309 of file variable.c.

References autoload, check_autoload_table(), DATA_PTR, ID, NODE, st_table::num_entries, rb_gc_force_recycle(), RCLASS, st_data_t, st_delete(), st_free_table(), st_lookup(), and VALUE.

Referenced by mod_av_set(), rb_autoload_load(), and rb_mod_remove_const().

VALUE autoload_file VALUE  mod,
ID  id
[static]
 

Definition at line 1350 of file variable.c.

References autoload, check_autoload_table(), Check_Type, DATA_PTR, ID, NODE, st_table::num_entries, Qnil, rb_eArgError, rb_gc_force_recycle(), rb_provided(), rb_raise(), RCLASS, RSTRING, st_data_t, st_delete(), st_free_table(), st_lookup(), T_STRING, and VALUE.

Referenced by rb_autoload_p(), and rb_const_defined_0().

struct st_table* check_autoload_table VALUE  av  )  [static]
 

Definition at line 1262 of file variable.c.

References Check_Type, DATA_PTR, rb_eTypeError, rb_inspect(), rb_mark_tbl(), rb_raise(), RDATA, RSTRING, RUBY_DATA_FUNC, st_free_table(), T_DATA, and VALUE.

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

VALUE classname VALUE  klass  )  [static]
 

Definition at line 144 of file variable.c.

References classpath, find_class_path(), ID, Qnil, rb_bug(), rb_cObject, rb_id2name(), rb_intern(), rb_str_new2(), RCLASS, ROBJECT, st_data_t, st_delete(), st_insert(), st_lookup(), SYM2ID, T_STRING, TYPE, and VALUE.

Referenced by rb_class_path(), and rb_mod_name().

VALUE const_missing VALUE  klass,
ID  id
[static]
 

Definition at line 1216 of file variable.c.

References ID, ID2SYM, rb_funcall(), rb_intern(), and VALUE.

Referenced by rb_const_get_0().

int cv_i ID  key,
VALUE  value,
VALUE  ary
[static]
 

Definition at line 1845 of file variable.c.

References ID, rb_ary_includes(), rb_ary_push(), rb_id2name(), rb_is_class_id(), rb_str_new2(), ST_CONTINUE, and VALUE.

Referenced by rb_mod_class_variables().

void cvar_override_check ID  id,
VALUE  a
[static]
 

Definition at line 1712 of file variable.c.

References ID, original_module(), rb_class2name(), rb_id2name(), rb_warning(), RCLASS, st_lookup(), and VALUE.

Referenced by rb_cvar_get(), and rb_cvar_set().

int fc_i ID  key,
VALUE  value,
struct fc_result res
[static]
 

Definition at line 71 of file variable.c.

References fc_i(), fc_path(), ID, fc_result::klass, fc_result::name, fc_result::path, fc_result::prev, rb_is_const_id(), RCLASS, ST_CONTINUE, st_data_t, st_foreach_safe(), ST_STOP, T_CLASS, T_MODULE, fc_result::track, TYPE, and VALUE.

Referenced by fc_i(), and find_class_path().

VALUE fc_path struct fc_result fc,
ID  name
[static]
 

Definition at line 44 of file variable.c.

References classpath, ID, name, rb_cObject, rb_id2name(), rb_str_append(), rb_str_cat2(), rb_str_dup(), rb_str_new2(), ROBJECT, st_lookup(), and VALUE.

Referenced by fc_i().

VALUE find_class_path VALUE  klass  )  [static]
 

Definition at line 116 of file variable.c.

References classpath, fc_i(), fc_result::klass, fc_result::name, fc_result::path, fc_result::prev, Qnil, rb_class_tbl, rb_cObject, RCLASS, ROBJECT, st_data_t, st_delete(), st_foreach(), st_foreach_safe(), st_init_numtable(), st_insert(), tmp_classpath, fc_result::track, and VALUE.

Referenced by classname().

VALUE generic_ivar_defined VALUE  obj,
ID  id
[static]
 

Definition at line 896 of file variable.c.

References generic_iv_tbl, ID, Qfalse, Qtrue, st_data_t, st_lookup(), and VALUE.

Referenced by rb_ivar_defined().

VALUE generic_ivar_get VALUE  obj,
ID  id,
int  warn
[static]
 

Definition at line 849 of file variable.c.

References generic_iv_tbl, ID, Qnil, rb_id2name(), rb_warning(), st_data_t, st_lookup(), and VALUE.

Referenced by ivar_get().

int generic_ivar_remove VALUE  obj,
ID  id,
VALUE valp
[static]
 

Definition at line 912 of file variable.c.

References generic_iv_tbl, ID, st_table::num_entries, st_data_t, st_delete(), st_free_table(), st_lookup(), and VALUE.

Referenced by rb_obj_remove_instance_variable().

void generic_ivar_set VALUE  obj,
ID  id,
VALUE  val
[static]
 

Definition at line 871 of file variable.c.

References FL_EXIVAR, FL_SET, generic_iv_tbl, ID, rb_special_const_p(), special_generic_ivar, st_add_direct(), st_data_t, st_init_numtable(), st_insert(), st_lookup(), and VALUE.

Referenced by rb_ivar_set().

int givar_i VALUE  obj,
st_table tbl
[static]
 

Definition at line 952 of file variable.c.

References givar_mark_i(), rb_special_const_p(), ST_CONTINUE, st_foreach(), and VALUE.

Referenced by rb_mark_generic_ivar_tbl().

int givar_mark_i ID  key,
VALUE  value
[static]
 

Definition at line 943 of file variable.c.

References ID, rb_gc_mark(), ST_CONTINUE, and VALUE.

Referenced by givar_i().

ID global_id char *  name  )  const [static]
 

Definition at line 478 of file variable.c.

References ALLOCA_N, ID, name, and rb_intern().

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

int gvar_i ID  key,
struct global_entry entry,
VALUE  ary
[static]
 

Definition at line 759 of file variable.c.

References ID, rb_ary_push(), rb_id2name(), rb_str_new2(), ST_CONTINUE, and VALUE.

Referenced by rb_f_global_variables().

void Init_var_tables void   ) 
 

Definition at line 26 of file variable.c.

References autoload, classpath, rb_class_tbl, rb_global_tbl, rb_intern(), st_init_numtable(), and tmp_classpath.

Referenced by rb_call_inits().

VALUE ivar_get VALUE  obj,
ID  id,
int  warn
[static]
 

Definition at line 1001 of file variable.c.

References FL_EXIVAR, FL_TEST, generic_ivar_get(), ID, Qnil, rb_id2name(), rb_special_const_p(), rb_warning(), ROBJECT, st_lookup(), T_CLASS, T_MODULE, T_OBJECT, TYPE, and VALUE.

Referenced by rb_attr_get(), and rb_ivar_get().

int ivar_i ID  key,
struct global_entry entry,
VALUE  ary
[static]
 

Definition at line 1086 of file variable.c.

References ID, rb_ary_push(), rb_id2name(), rb_is_instance_id(), rb_str_new2(), ST_CONTINUE, and VALUE.

Referenced by rb_obj_instance_variables().

int list_i ID  key,
ID  value,
VALUE  ary
[static]
 

Definition at line 1541 of file variable.c.

References ID, rb_ary_push(), rb_id2name(), rb_str_new2(), ST_CONTINUE, and VALUE.

Referenced by rb_const_list().

int mark_global_entry ID  key,
struct global_entry entry
[static]
 

Definition at line 453 of file variable.c.

References ID, rb_gc_mark_maybe(), and ST_CONTINUE.

Referenced by rb_gc_mark_global_tbl().

void mod_av_set VALUE  klass,
ID  id,
VALUE  val,
int  isconst
[static]
 

Definition at line 1633 of file variable.c.

References autoload_delete(), BUILTIN_TYPE, ID, OBJ_FROZEN, OBJ_TAINTED, Qfalse, Qundef, rb_error_frozen(), rb_eSecurityError, rb_id2name(), rb_raise(), rb_safe_level, rb_warn(), RCLASS, st_init_numtable(), st_insert(), st_lookup(), T_MODULE, and VALUE.

Referenced by rb_const_set(), and rb_cvar_set().

VALUE original_module VALUE  c  )  [static]
 

Definition at line 1703 of file variable.c.

References RBASIC, T_ICLASS, TYPE, and VALUE.

Referenced by cvar_override_check().

VALUE rb_class_name VALUE  klass  ) 
 

Definition at line 286 of file variable.c.

References rb_class_path(), rb_class_real(), and VALUE.

Referenced by error_print(), exc_inspect(), exc_to_s(), name_err_to_s(), rb_class2name(), and rb_mod_to_s().

int rb_const_defined_0 VALUE  klass,
ID  id,
int  exclude,
int  recurse
[static]
 

Definition at line 1581 of file variable.c.

References autoload_file(), BUILTIN_TYPE, ID, NIL_P, Qfalse, Qtrue, Qundef, rb_cObject, RCLASS, st_lookup(), T_MODULE, and VALUE.

Referenced by rb_const_defined(), rb_const_defined_at(), and rb_const_defined_from().

VALUE rb_const_get_0 VALUE  klass,
ID  id,
int  exclude,
int  recurse
[static]
 

Definition at line 1399 of file variable.c.

References BUILTIN_TYPE, const_missing(), ID, Qundef, rb_autoload_load(), rb_class2name(), rb_cObject, rb_id2name(), rb_warn(), RCLASS, RTEST, st_lookup(), T_MODULE, and VALUE.

Referenced by rb_const_get(), rb_const_get_at(), and rb_const_get_from().

void rb_define_global_const char *  name,
VALUE  val
const
 

Definition at line 1695 of file variable.c.

References name, rb_cObject, rb_define_const(), and VALUE.

Referenced by Init_Hash(), Init_IO(), Init_Object(), Init_Regexp(), Init_version(), load_file(), ruby_init(), and ruby_prog_init().

void rb_define_hooked_variable char *  name,
VALUE var,
getter  ,
setter 
const
 

Definition at line 494 of file variable.c.

References global_variable::data, global_id(), ID, name, rb_global_entry(), VALUE, global_entry::var, var_getter(), var_marker(), and var_setter().

Referenced by Init_eval(), Init_IO(), rb_define_readonly_variable(), rb_define_variable(), rb_define_virtual_variable(), and ruby_prog_init().

void rb_define_readonly_variable char *  name,
VALUE var
const
 

Definition at line 519 of file variable.c.

References name, rb_define_hooked_variable(), readonly_setter(), and VALUE.

Referenced by Init_IO(), Init_load(), Init_process(), and ruby_prog_init().

void rb_define_variable char *  name,
VALUE var
const
 

Definition at line 511 of file variable.c.

References name, rb_define_hooked_variable(), and VALUE.

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

void rb_define_virtual_variable char *  name,
getter  ,
setter 
const
 

Definition at line 527 of file variable.c.

References name, rb_define_hooked_variable(), readonly_setter(), and val_getter().

Referenced by Init_eval(), Init_IO(), Init_process(), and Init_Regexp().

struct global_entry* rb_global_entry ID  id  ) 
 

Definition at line 341 of file variable.c.

References ALLOC, ID, rb_global_tbl, st_add_direct(), st_data_t, st_lookup(), undef_getter(), undef_marker(), and undef_setter().

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

VALUE rb_gv_get char *  name  )  const
 

Definition at line 741 of file variable.c.

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

VALUE rb_gv_set char *  name,
VALUE  val
const
 

Definition at line 730 of file variable.c.

References global_id(), name, rb_global_entry(), rb_gvar_set(), and VALUE.

Referenced by process_sflag().

VALUE rb_gvar_defined struct global_entry entry  ) 
 

Definition at line 751 of file variable.c.

References Qfalse, Qtrue, and undef_getter().

Referenced by is_defined().

VALUE rb_gvar_get struct global_entry entry  ) 
 

Definition at line 674 of file variable.c.

Referenced by rb_eval(), and rb_gv_get().

VALUE rb_gvar_set struct global_entry entry,
VALUE  val
 

Definition at line 709 of file variable.c.

References rb_ensure(), rb_eSecurityError, rb_raise(), rb_safe_level, trace_data::trace, trace_en(), trace_ev(), trace_data::val, and VALUE.

Referenced by assign(), rb_eval(), and rb_gv_set().

VALUE rb_path2class char *  path  )  const
 

Definition at line 238 of file variable.c.

References ID, rb_cObject, rb_const_defined(), rb_const_get_at(), rb_eArgError, rb_eTypeError, rb_intern(), rb_raise(), rb_str_new(), RSTRING, T_CLASS, T_MODULE, TYPE, and VALUE.

Referenced by class2path(), path2class(), path2module(), and r_object0().

void rb_trace_eval VALUE  cmd,
VALUE  val
[static]
 

Definition at line 538 of file variable.c.

References cmd, rb_ary_new3(), rb_eval_cmd(), and VALUE.

Referenced by rb_f_trace_var().

void readonly_setter VALUE  val,
ID  id,
void *  var
[static]
 

Definition at line 444 of file variable.c.

References ID, rb_id2name(), rb_name_error(), and VALUE.

Referenced by rb_define_readonly_variable(), and rb_define_virtual_variable().

void remove_trace struct global_variable var  )  [static]
 

Definition at line 598 of file variable.c.

References free, and trace_var::next.

Referenced by rb_f_untrace_var(), and trace_en().

int sv_i ID  key,
VALUE  value,
st_table tbl
[static]
 

Definition at line 1497 of file variable.c.

References ID, rb_is_const_id(), ST_CONTINUE, st_insert(), st_lookup(), and VALUE.

Referenced by rb_mod_const_at().

VALUE trace_en struct global_variable var  )  [static]
 

Definition at line 700 of file variable.c.

References Qnil, and remove_trace().

Referenced by rb_gvar_set().

VALUE trace_ev struct trace_data data  )  [static]
 

Definition at line 687 of file variable.c.

References Qnil.

Referenced by rb_gvar_set().

VALUE undef_getter ID  id  )  [static]
 

Definition at line 366 of file variable.c.

References ID, Qnil, rb_id2name(), and rb_warning().