2010-10-26 13:27:32 -04:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
constant.h -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: Sun Nov 15 00:09:33 2009
|
|
|
|
|
|
|
|
Copyright (C) 2009 Yusuke Endoh
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
#ifndef CONSTANT_H
|
|
|
|
#define CONSTANT_H
|
2019-12-04 03:16:30 -05:00
|
|
|
#include "ruby/ruby.h"
|
|
|
|
#include "id_table.h"
|
2010-10-26 13:27:32 -04:00
|
|
|
|
|
|
|
typedef enum {
|
2015-07-30 00:20:00 -04:00
|
|
|
CONST_DEPRECATED = 0x100,
|
|
|
|
|
|
|
|
CONST_VISIBILITY_MASK = 0xff,
|
2010-10-26 13:27:32 -04:00
|
|
|
CONST_PUBLIC = 0x00,
|
2014-10-08 04:27:51 -04:00
|
|
|
CONST_PRIVATE,
|
|
|
|
CONST_VISIBILITY_MAX
|
2010-10-26 13:27:32 -04:00
|
|
|
} rb_const_flag_t;
|
|
|
|
|
2014-10-08 04:27:51 -04:00
|
|
|
#define RB_CONST_PRIVATE_P(ce) \
|
2015-07-30 00:20:00 -04:00
|
|
|
(((ce)->flag & CONST_VISIBILITY_MASK) == CONST_PRIVATE)
|
2014-10-08 04:27:51 -04:00
|
|
|
#define RB_CONST_PUBLIC_P(ce) \
|
2015-07-30 00:20:00 -04:00
|
|
|
(((ce)->flag & CONST_VISIBILITY_MASK) == CONST_PUBLIC)
|
|
|
|
|
|
|
|
#define RB_CONST_DEPRECATED_P(ce) \
|
|
|
|
((ce)->flag & CONST_DEPRECATED)
|
2014-10-08 04:27:51 -04:00
|
|
|
|
2010-10-26 13:27:32 -04:00
|
|
|
typedef struct rb_const_entry_struct {
|
|
|
|
rb_const_flag_t flag;
|
2014-02-06 15:33:03 -05:00
|
|
|
int line;
|
2019-04-19 21:19:47 -04:00
|
|
|
VALUE value; /* should be mark */
|
|
|
|
VALUE file; /* should be mark */
|
2010-10-26 13:27:32 -04:00
|
|
|
} rb_const_entry_t;
|
|
|
|
|
2014-06-18 02:16:39 -04:00
|
|
|
VALUE rb_mod_private_constant(int argc, const VALUE *argv, VALUE obj);
|
|
|
|
VALUE rb_mod_public_constant(int argc, const VALUE *argv, VALUE obj);
|
2015-07-30 00:20:00 -04:00
|
|
|
VALUE rb_mod_deprecate_constant(int argc, const VALUE *argv, VALUE obj);
|
use id_table for constant tables
valgrind 3.9.0 on x86-64 reports a minor reduction in memory usage
when loading only RubyGems and RDoc by running: ruby -rrdoc -eexit
before: HEAP SUMMARY:
in use at exit: 2,913,448 bytes in 27,394 blocks
total heap usage: 48,362 allocs, 20,968 frees, 9,034,621 bytes alloc
after: HEAP SUMMARY:
in use at exit: 2,880,056 bytes in 26,712 blocks
total heap usage: 47,791 allocs, 21,079 frees, 9,046,507 bytes alloc
* class.c (struct clone_const_arg): adjust for id_table
(clone_const): ditto
(clone_const_i): ditto
(rb_mod_init_copy): ditto
(rb_singleton_class_clone_and_attach): ditto
(rb_include_class_new): ditto
(include_modules_at): ditto
* constant.h (rb_free_const_table): ditto
* gc.c (free_const_entry_i): ditto
(rb_free_const_table): ditto
(obj_memsize_of): ditto
(mark_const_entry_i): ditto
(mark_const_tbl): ditto
* internal.h (struct rb_classext_struct): ditto
* object.c (rb_mod_const_set): resolve class name on assignment
* variable.c (const_update): replace with const_tbl_update
(const_tbl_update): new function
(fc_i): adjust for id_table
(find_class_path): ditto
(autoload_const_set): st_update => const_tbl_update
(rb_const_remove): adjust for id_table
(sv_i): ditto
(rb_local_constants_i): ditto
(rb_local_constants): ditto
(rb_mod_const_at): ditto
(rb_mod_const_set): ditto
(rb_const_lookup): ditto
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53376 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-29 15:19:14 -05:00
|
|
|
void rb_free_const_table(struct rb_id_table *tbl);
|
2019-12-03 01:11:09 -05:00
|
|
|
VALUE rb_const_source_location(VALUE, ID);
|
|
|
|
|
|
|
|
MJIT_SYMBOL_EXPORT_BEGIN
|
|
|
|
int rb_autoloading_value(VALUE mod, ID id, VALUE *value, rb_const_flag_t *flag);
|
|
|
|
rb_const_entry_t *rb_const_lookup(VALUE klass, ID id);
|
2011-01-28 12:57:27 -05:00
|
|
|
VALUE rb_public_const_get_at(VALUE klass, ID id);
|
|
|
|
VALUE rb_public_const_get_from(VALUE klass, ID id);
|
|
|
|
int rb_public_const_defined_from(VALUE klass, ID id);
|
2018-12-13 07:49:05 -05:00
|
|
|
VALUE rb_const_source_location_at(VALUE, ID);
|
2019-12-03 01:11:09 -05:00
|
|
|
MJIT_SYMBOL_EXPORT_END
|
2010-10-26 13:27:32 -04:00
|
|
|
|
|
|
|
#endif /* CONSTANT_H */
|