* eval_load.c, yarvcore.h: use rb_vm_t#loaded_features instead of

rb_features (global variable).
* yarvcore.c: mark rb_vm_t#loaded_features.



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11720 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
ko1 2007-02-14 02:19:02 +00:00
Родитель 9ba43ab6d4
Коммит 9895ce9f77
4 изменённых файлов: 26 добавлений и 10 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Wed Feb 14 11:12:02 2007 Koichi Sasada <ko1@atdot.net>
* eval_load.c, yarvcore.h: use rb_vm_t#loaded_features instead of
rb_features (global variable).
* yarvcore.c: mark rb_vm_t#loaded_features.
Wed Feb 14 08:46:25 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
* compile.c (defined_expr): no longer distinguish ordinary local

Просмотреть файл

@ -7,11 +7,8 @@
extern VALUE ruby_top_self;
VALUE ruby_dln_librefs;
static VALUE rb_features;
static st_table *loading_tbl;
NORETURN(void jump_tag_but_local_jump(int, VALUE));
#define IS_SOEXT(e) (strcmp(e, ".so") == 0 || strcmp(e, ".o") == 0)
#ifdef DLEXT2
#define IS_DLEXT(e) (strcmp(e, DLEXT) == 0 || strcmp(e, DLEXT2) == 0)
@ -19,6 +16,12 @@ NORETURN(void jump_tag_but_local_jump(int, VALUE));
#define IS_DLEXT(e) (strcmp(e, DLEXT) == 0)
#endif
static VALUE
get_loaded_features(void)
{
return GET_VM()->loaded_features;
}
static int
rb_feature_p(const char *feature, const char *ext, int rb)
{
@ -34,8 +37,8 @@ rb_feature_p(const char *feature, const char *ext, int rb)
len = strlen(feature);
elen = 0;
}
for (i = 0; i < RARRAY_LEN(rb_features); ++i) {
v = RARRAY_PTR(rb_features)[i];
for (i = 0; i < RARRAY_LEN(get_loaded_features()); ++i) {
v = RARRAY_PTR(get_loaded_features())[i];
f = StringValuePtr(v);
if (strncmp(f, feature, len) != 0)
continue;
@ -99,7 +102,7 @@ rb_provided(const char *feature)
static void
rb_provide_feature(VALUE feature)
{
rb_ary_push(rb_features, feature);
rb_ary_push(get_loaded_features(), feature);
}
void
@ -518,9 +521,9 @@ Init_load()
rb_define_readonly_variable("$-I", &rb_load_path);
rb_define_readonly_variable("$LOAD_PATH", &rb_load_path);
rb_features = rb_ary_new();
rb_define_readonly_variable("$\"", &rb_features);
rb_define_readonly_variable("$LOADED_FEATURES", &rb_features);
rb_define_virtual_variable("$\"", get_loaded_features, 0);
rb_define_virtual_variable("$LOADED_FEATURES", get_loaded_features, 0);
GET_VM()->loaded_features = rb_ary_new();
rb_define_global_function("load", rb_f_load, -1);
rb_define_global_function("require", rb_f_require, 1);

Просмотреть файл

@ -182,7 +182,9 @@ vm_mark(void *ptr)
MARK_UNLESS_NULL(vm->thgroup_default);
MARK_UNLESS_NULL(vm->mark_object_ary);
MARK_UNLESS_NULL(vm->last_status);
MARK_UNLESS_NULL(vm->loaded_features);
}
MARK_REPORT_LEAVE("vm");
}
@ -512,9 +514,9 @@ Init_VM(void)
/* create vm object */
VALUE vmval = vm_alloc(rb_cVM);
VALUE thval;
rb_vm_t *vm;
rb_thread_t *th;
vm = theYarvVM;
xfree(RDATA(vmval)->data);

Просмотреть файл

@ -327,6 +327,10 @@ typedef struct rb_vm_struct {
/* object management */
VALUE mark_object_ary;
/* load */
VALUE loaded_features;
/* signal */
rb_atomic_t signal_buff[RUBY_NSIG];
rb_atomic_t bufferd_signal_size;
} rb_vm_t;