mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* internal.h: define rb_cref_t and change to use it.
rb_cref_t is data type of CREF. Now, the body is still NODE. It is easy to understand what is CREF and what is pure NODE. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2324c14d00
commit
8dced4d2c0
16 changed files with 181 additions and 100 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
Mon Mar 9 06:19:06 2015 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* internal.h: define rb_cref_t and change to use it.
|
||||||
|
|
||||||
|
rb_cref_t is data type of CREF. Now, the body is still NODE.
|
||||||
|
It is easy to understand what is CREF and what is pure NODE.
|
||||||
|
|
||||||
Mon Mar 9 06:00:37 2015 Koichi Sasada <ko1@atdot.net>
|
Mon Mar 9 06:00:37 2015 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
* vm_insnhelper.h (COPY_CREF_OMOD): fix translation miss.
|
* vm_insnhelper.h (COPY_CREF_OMOD): fix translation miss.
|
||||||
|
|
2
class.c
2
class.c
|
@ -246,7 +246,7 @@ clone_method(VALUE klass, ID mid, const rb_method_entry_t *me)
|
||||||
VALUE newiseqval;
|
VALUE newiseqval;
|
||||||
if (me->def && me->def->type == VM_METHOD_TYPE_ISEQ) {
|
if (me->def && me->def->type == VM_METHOD_TYPE_ISEQ) {
|
||||||
rb_iseq_t *iseq;
|
rb_iseq_t *iseq;
|
||||||
NODE *new_cref;
|
rb_cref_t *new_cref;
|
||||||
newiseqval = rb_iseq_clone(me->def->body.iseq_body.iseq->self, klass);
|
newiseqval = rb_iseq_clone(me->def->body.iseq_body.iseq->self, klass);
|
||||||
GetISeqPtr(newiseqval, iseq);
|
GetISeqPtr(newiseqval, iseq);
|
||||||
rb_vm_rewrite_cref_stack(me->def->body.iseq_body.cref, me->klass, klass, &new_cref);
|
rb_vm_rewrite_cref_stack(me->def->body.iseq_body.cref, me->klass, klass, &new_cref);
|
||||||
|
|
20
eval.c
20
eval.c
|
@ -341,7 +341,7 @@ static VALUE
|
||||||
rb_mod_nesting(void)
|
rb_mod_nesting(void)
|
||||||
{
|
{
|
||||||
VALUE ary = rb_ary_new();
|
VALUE ary = rb_ary_new();
|
||||||
const NODE *cref = rb_vm_cref();
|
const rb_cref_t *cref = rb_vm_cref();
|
||||||
|
|
||||||
while (cref && CREF_NEXT(cref)) {
|
while (cref && CREF_NEXT(cref)) {
|
||||||
VALUE klass = CREF_CLASS(cref);
|
VALUE klass = CREF_CLASS(cref);
|
||||||
|
@ -379,7 +379,7 @@ rb_mod_nesting(void)
|
||||||
static VALUE
|
static VALUE
|
||||||
rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
|
rb_mod_s_constants(int argc, VALUE *argv, VALUE mod)
|
||||||
{
|
{
|
||||||
const NODE *cref = rb_vm_cref();
|
const rb_cref_t *cref = rb_vm_cref();
|
||||||
VALUE klass;
|
VALUE klass;
|
||||||
VALUE cbase = 0;
|
VALUE cbase = 0;
|
||||||
void *data = 0;
|
void *data = 0;
|
||||||
|
@ -1154,18 +1154,18 @@ hidden_identity_hash_new(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_using_refinement(NODE *cref, VALUE klass, VALUE module)
|
rb_using_refinement(rb_cref_t *cref, VALUE klass, VALUE module)
|
||||||
{
|
{
|
||||||
VALUE iclass, c, superclass = klass;
|
VALUE iclass, c, superclass = klass;
|
||||||
|
|
||||||
Check_Type(klass, T_CLASS);
|
Check_Type(klass, T_CLASS);
|
||||||
Check_Type(module, T_MODULE);
|
Check_Type(module, T_MODULE);
|
||||||
if (NIL_P(CREF_REFINEMENTS(cref))) {
|
if (NIL_P(CREF_REFINEMENTS(cref))) {
|
||||||
RB_OBJ_WRITE(cref, &CREF_REFINEMENTS(cref), hidden_identity_hash_new());
|
CREF_REFINEMENTS_SET(cref, hidden_identity_hash_new());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (CREF_OMOD_SHARED(cref)) {
|
if (CREF_OMOD_SHARED(cref)) {
|
||||||
RB_OBJ_WRITE(cref, &CREF_REFINEMENTS(cref), rb_hash_dup(CREF_REFINEMENTS(cref)));
|
CREF_REFINEMENTS_SET(cref, rb_hash_dup(CREF_REFINEMENTS(cref)));
|
||||||
CREF_OMOD_SHARED_UNSET(cref);
|
CREF_OMOD_SHARED_UNSET(cref);
|
||||||
}
|
}
|
||||||
if (!NIL_P(c = rb_hash_lookup(CREF_REFINEMENTS(cref), klass))) {
|
if (!NIL_P(c = rb_hash_lookup(CREF_REFINEMENTS(cref), klass))) {
|
||||||
|
@ -1199,14 +1199,14 @@ rb_using_refinement(NODE *cref, VALUE klass, VALUE module)
|
||||||
static int
|
static int
|
||||||
using_refinement(VALUE klass, VALUE module, VALUE arg)
|
using_refinement(VALUE klass, VALUE module, VALUE arg)
|
||||||
{
|
{
|
||||||
NODE *cref = (NODE *) arg;
|
rb_cref_t *cref = (rb_cref_t *) arg;
|
||||||
|
|
||||||
rb_using_refinement(cref, klass, module);
|
rb_using_refinement(cref, klass, module);
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
using_module_recursive(NODE *cref, VALUE klass)
|
using_module_recursive(const rb_cref_t *cref, VALUE klass)
|
||||||
{
|
{
|
||||||
ID id_refinements;
|
ID id_refinements;
|
||||||
VALUE super, module, refinements;
|
VALUE super, module, refinements;
|
||||||
|
@ -1236,7 +1236,7 @@ using_module_recursive(NODE *cref, VALUE klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_using_module(NODE *cref, VALUE module)
|
rb_using_module(const rb_cref_t *cref, VALUE module)
|
||||||
{
|
{
|
||||||
Check_Type(module, T_MODULE);
|
Check_Type(module, T_MODULE);
|
||||||
using_module_recursive(cref, module);
|
using_module_recursive(cref, module);
|
||||||
|
@ -1348,7 +1348,7 @@ rb_mod_refine(VALUE module, VALUE klass)
|
||||||
static VALUE
|
static VALUE
|
||||||
mod_using(VALUE self, VALUE module)
|
mod_using(VALUE self, VALUE module)
|
||||||
{
|
{
|
||||||
NODE *cref = rb_vm_cref();
|
const rb_cref_t *cref = rb_vm_cref();
|
||||||
rb_control_frame_t *prev_cfp = previous_frame(GET_THREAD());
|
rb_control_frame_t *prev_cfp = previous_frame(GET_THREAD());
|
||||||
|
|
||||||
if (prev_frame_func()) {
|
if (prev_frame_func()) {
|
||||||
|
@ -1485,7 +1485,7 @@ top_include(int argc, VALUE *argv, VALUE self)
|
||||||
static VALUE
|
static VALUE
|
||||||
top_using(VALUE self, VALUE module)
|
top_using(VALUE self, VALUE module)
|
||||||
{
|
{
|
||||||
NODE *cref = rb_vm_cref();
|
const rb_cref_t *cref = rb_vm_cref();
|
||||||
rb_control_frame_t *prev_cfp = previous_frame(GET_THREAD());
|
rb_control_frame_t *prev_cfp = previous_frame(GET_THREAD());
|
||||||
|
|
||||||
if (CREF_NEXT(cref) || (prev_cfp && prev_cfp->me)) {
|
if (CREF_NEXT(cref) || (prev_cfp && prev_cfp->me)) {
|
||||||
|
|
|
@ -245,7 +245,7 @@ NORETURN(void rb_raise_method_missing(rb_thread_t *th, int argc, const VALUE *ar
|
||||||
VALUE obj, int call_status));
|
VALUE obj, int call_status));
|
||||||
|
|
||||||
VALUE rb_vm_make_jump_tag_but_local_jump(int state, VALUE val);
|
VALUE rb_vm_make_jump_tag_but_local_jump(int state, VALUE val);
|
||||||
NODE *rb_vm_cref(void);
|
rb_cref_t *rb_vm_cref(void);
|
||||||
VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, const rb_block_t *blockptr, VALUE filename);
|
VALUE rb_vm_call_cfunc(VALUE recv, VALUE (*func)(VALUE), VALUE arg, const rb_block_t *blockptr, VALUE filename);
|
||||||
void rb_vm_set_progname(VALUE filename);
|
void rb_vm_set_progname(VALUE filename);
|
||||||
void rb_thread_terminate_all(void);
|
void rb_thread_terminate_all(void);
|
||||||
|
|
|
@ -159,8 +159,7 @@ getclassvariable
|
||||||
()
|
()
|
||||||
(VALUE val)
|
(VALUE val)
|
||||||
{
|
{
|
||||||
NODE *cref = rb_vm_get_cref(GET_EP());
|
val = rb_cvar_get(vm_get_cvar_base(rb_vm_get_cref(GET_EP()), GET_CFP()), id);
|
||||||
val = rb_cvar_get(vm_get_cvar_base(cref, GET_CFP()), id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -174,8 +173,7 @@ setclassvariable
|
||||||
(VALUE val)
|
(VALUE val)
|
||||||
()
|
()
|
||||||
{
|
{
|
||||||
NODE *cref = rb_vm_get_cref(GET_EP());
|
rb_cvar_set(vm_get_cvar_base(rb_vm_get_cref(GET_EP()), GET_CFP()), id, val);
|
||||||
rb_cvar_set(vm_get_cvar_base(cref, GET_CFP()), id, val);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -738,7 +736,7 @@ defined
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DEFINED_CVAR: {
|
case DEFINED_CVAR: {
|
||||||
NODE *cref = rb_vm_get_cref(GET_EP());
|
const rb_cref_t *cref = rb_vm_get_cref(GET_EP());
|
||||||
klass = vm_get_cvar_base(cref, GET_CFP());
|
klass = vm_get_cvar_base(cref, GET_CFP());
|
||||||
if (rb_cvar_defined(klass, SYM2ID(obj))) {
|
if (rb_cvar_defined(klass, SYM2ID(obj))) {
|
||||||
expr_type = DEFINED_CVAR;
|
expr_type = DEFINED_CVAR;
|
||||||
|
|
99
internal.h
99
internal.h
|
@ -506,16 +506,95 @@ RCLASS_SET_SUPER(VALUE klass, VALUE super)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CREF */
|
/* CREF */
|
||||||
#define CREF_CLASS(cref) ((cref)->nd_clss_)
|
|
||||||
#define CREF_NEXT(cref) ((cref)->nd_next)
|
typedef struct rb_cref_struct {
|
||||||
#define CREF_VISI(cref) ((cref)->nd_visi_)
|
VALUE flags;
|
||||||
#define CREF_VISI_SET(cref, v) ((cref)->nd_visi_ = (v))
|
VALUE refinements;
|
||||||
#define CREF_REFINEMENTS(cref) ((cref)->nd_refinements_)
|
VALUE klass;
|
||||||
#define CREF_PUSHED_BY_EVAL(cref) ((cref)->flags & NODE_FL_CREF_PUSHED_BY_EVAL_)
|
VALUE visi;
|
||||||
#define CREF_PUSHED_BY_EVAL_SET(cref) ((cref)->flags |= NODE_FL_CREF_PUSHED_BY_EVAL_)
|
struct rb_cref_struct *next;
|
||||||
#define CREF_OMOD_SHARED(cref) ((cref)->flags & NODE_FL_CREF_OMOD_SHARED_)
|
} rb_cref_t;
|
||||||
#define CREF_OMOD_SHARED_SET(cref) ((cref)->flags |= NODE_FL_CREF_OMOD_SHARED_)
|
|
||||||
#define CREF_OMOD_SHARED_UNSET(cref) ((cref)->flags &= ~NODE_FL_CREF_OMOD_SHARED_)
|
#define NODE_FL_CREF_PUSHED_BY_EVAL_ (((VALUE)1)<<15)
|
||||||
|
#define NODE_FL_CREF_OMOD_SHARED_ (((VALUE)1)<<16)
|
||||||
|
|
||||||
|
static inline VALUE
|
||||||
|
CREF_CLASS(const rb_cref_t *cref)
|
||||||
|
{
|
||||||
|
return cref->klass;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
CREF_CLASS_SET(rb_cref_t *cref, VALUE klass)
|
||||||
|
{
|
||||||
|
RB_OBJ_WRITE(cref, &cref->klass, klass);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline rb_cref_t *
|
||||||
|
CREF_NEXT(const rb_cref_t *cref)
|
||||||
|
{
|
||||||
|
return cref->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
CREF_NEXT_SET(rb_cref_t *cref, const rb_cref_t *next_cref)
|
||||||
|
{
|
||||||
|
RB_OBJ_WRITE(cref, &cref->next, next_cref);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline long
|
||||||
|
CREF_VISI(const rb_cref_t *cref)
|
||||||
|
{
|
||||||
|
return (long)cref->visi;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
CREF_VISI_SET(rb_cref_t *cref, long v)
|
||||||
|
{
|
||||||
|
cref->visi = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline VALUE
|
||||||
|
CREF_REFINEMENTS(const rb_cref_t *cref)
|
||||||
|
{
|
||||||
|
return cref->refinements;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
CREF_REFINEMENTS_SET(rb_cref_t *cref, VALUE refs)
|
||||||
|
{
|
||||||
|
RB_OBJ_WRITE(cref, &cref->refinements, refs);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
CREF_PUSHED_BY_EVAL(const rb_cref_t *cref)
|
||||||
|
{
|
||||||
|
return cref->flags & NODE_FL_CREF_PUSHED_BY_EVAL_;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
CREF_PUSHED_BY_EVAL_SET(rb_cref_t *cref)
|
||||||
|
{
|
||||||
|
cref->flags |= NODE_FL_CREF_PUSHED_BY_EVAL_;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int
|
||||||
|
CREF_OMOD_SHARED(const rb_cref_t *cref)
|
||||||
|
{
|
||||||
|
return cref->flags & NODE_FL_CREF_OMOD_SHARED_;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
CREF_OMOD_SHARED_SET(rb_cref_t *cref)
|
||||||
|
{
|
||||||
|
cref->flags |= NODE_FL_CREF_OMOD_SHARED_;
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
CREF_OMOD_SHARED_UNSET(rb_cref_t *cref)
|
||||||
|
{
|
||||||
|
cref->flags &= ~NODE_FL_CREF_OMOD_SHARED_;
|
||||||
|
}
|
||||||
|
|
||||||
struct vtm; /* defined by timev.h */
|
struct vtm; /* defined by timev.h */
|
||||||
|
|
||||||
|
|
4
method.h
4
method.h
|
@ -84,7 +84,7 @@ typedef struct rb_method_definition_struct {
|
||||||
union {
|
union {
|
||||||
struct {
|
struct {
|
||||||
rb_iseq_t *const iseq; /* should be mark */
|
rb_iseq_t *const iseq; /* should be mark */
|
||||||
NODE *cref;
|
rb_cref_t *cref;
|
||||||
} iseq_body;
|
} iseq_body;
|
||||||
rb_method_cfunc_t cfunc;
|
rb_method_cfunc_t cfunc;
|
||||||
rb_method_attr_t attr;
|
rb_method_attr_t attr;
|
||||||
|
@ -118,7 +118,7 @@ struct unlinked_method_entry_list_entry {
|
||||||
UNDEFINED_METHOD_ENTRY_P((def)->body.orig_me))
|
UNDEFINED_METHOD_ENTRY_P((def)->body.orig_me))
|
||||||
|
|
||||||
void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex);
|
void rb_add_method_cfunc(VALUE klass, ID mid, VALUE (*func)(ANYARGS), int argc, rb_method_flag_t noex);
|
||||||
void rb_add_method_iseq(VALUE klass, ID mid, rb_iseq_t *iseq, NODE *cref, rb_method_flag_t noex);
|
void rb_add_method_iseq(VALUE klass, ID mid, rb_iseq_t *iseq, rb_cref_t *cref, rb_method_flag_t noex);
|
||||||
rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex);
|
rb_method_entry_t *rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *option, rb_method_flag_t noex);
|
||||||
rb_method_entry_t *rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr);
|
rb_method_entry_t *rb_method_entry(VALUE klass, ID id, VALUE *define_class_ptr);
|
||||||
rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
|
rb_method_entry_t *rb_method_entry_at(VALUE obj, ID id);
|
||||||
|
|
8
node.c
8
node.c
|
@ -947,7 +947,7 @@ rb_gc_mark_node(NODE *obj)
|
||||||
{
|
{
|
||||||
switch (nd_type(obj)) {
|
switch (nd_type(obj)) {
|
||||||
case NODE_IF: /* 1,2,3 */
|
case NODE_IF: /* 1,2,3 */
|
||||||
rb_gc_mark(CREF_REFINEMENTS(obj)); /* use as SVAR */
|
rb_gc_mark(CREF_REFINEMENTS((rb_cref_t *)obj)); /* use as SVAR */
|
||||||
case NODE_FOR:
|
case NODE_FOR:
|
||||||
case NODE_ITER:
|
case NODE_ITER:
|
||||||
case NODE_WHEN:
|
case NODE_WHEN:
|
||||||
|
@ -1070,9 +1070,9 @@ rb_gc_mark_node(NODE *obj)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NODE_CREF:
|
case NODE_CREF:
|
||||||
rb_gc_mark(CREF_REFINEMENTS(obj));
|
rb_gc_mark(CREF_REFINEMENTS((rb_cref_t *)obj));
|
||||||
rb_gc_mark(CREF_CLASS(obj));
|
rb_gc_mark(CREF_CLASS((rb_cref_t *)obj));
|
||||||
return (VALUE)CREF_NEXT(obj);;
|
return (VALUE)CREF_NEXT((rb_cref_t *)obj);
|
||||||
|
|
||||||
default: /* unlisted NODE */
|
default: /* unlisted NODE */
|
||||||
rb_gc_mark_maybe(RNODE(obj)->u1.value);
|
rb_gc_mark_maybe(RNODE(obj)->u1.value);
|
||||||
|
|
2
node.h
2
node.h
|
@ -273,8 +273,6 @@ typedef struct RNode {
|
||||||
* 16: NODE_FL_CREF_OMOD_SHARED
|
* 16: NODE_FL_CREF_OMOD_SHARED
|
||||||
*/
|
*/
|
||||||
#define NODE_FL_NEWLINE (((VALUE)1)<<7)
|
#define NODE_FL_NEWLINE (((VALUE)1)<<7)
|
||||||
#define NODE_FL_CREF_PUSHED_BY_EVAL_ (((VALUE)1)<<15)
|
|
||||||
#define NODE_FL_CREF_OMOD_SHARED_ (((VALUE)1)<<16)
|
|
||||||
|
|
||||||
#define NODE_TYPESHIFT 8
|
#define NODE_TYPESHIFT 8
|
||||||
#define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
|
#define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT)
|
||||||
|
|
6
proc.c
6
proc.c
|
@ -14,7 +14,7 @@
|
||||||
#include "gc.h"
|
#include "gc.h"
|
||||||
#include "iseq.h"
|
#include "iseq.h"
|
||||||
|
|
||||||
const NODE *rb_vm_cref_in_context(VALUE self, VALUE cbase);
|
const rb_cref_t *rb_vm_cref_in_context(VALUE self, VALUE cbase);
|
||||||
|
|
||||||
struct METHOD {
|
struct METHOD {
|
||||||
VALUE recv;
|
VALUE recv;
|
||||||
|
@ -1639,7 +1639,7 @@ rb_mod_define_method(int argc, VALUE *argv, VALUE mod)
|
||||||
ID id;
|
ID id;
|
||||||
VALUE body;
|
VALUE body;
|
||||||
int noex = NOEX_PUBLIC;
|
int noex = NOEX_PUBLIC;
|
||||||
const NODE *cref = rb_vm_cref_in_context(mod, mod);
|
const rb_cref_t *cref = rb_vm_cref_in_context(mod, mod);
|
||||||
|
|
||||||
if (cref) {
|
if (cref) {
|
||||||
noex = CREF_VISI(cref);
|
noex = CREF_VISI(cref);
|
||||||
|
@ -2167,7 +2167,7 @@ method_get_iseq(rb_method_definition_t *def)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static NODE *
|
static const rb_cref_t *
|
||||||
method_get_cref(rb_method_definition_t *def)
|
method_get_cref(rb_method_definition_t *def)
|
||||||
{
|
{
|
||||||
switch (def->type) {
|
switch (def->type) {
|
||||||
|
|
32
vm.c
32
vm.c
|
@ -79,20 +79,20 @@ rb_vm_control_frame_block_ptr(const rb_control_frame_t *cfp)
|
||||||
return VM_CF_BLOCK_PTR(cfp);
|
return VM_CF_BLOCK_PTR(cfp);
|
||||||
}
|
}
|
||||||
|
|
||||||
static NODE *
|
static rb_cref_t *
|
||||||
vm_cref_new(VALUE klass, long visi, NODE *prev_cref)
|
vm_cref_new(VALUE klass, long visi, const rb_cref_t *prev_cref)
|
||||||
{
|
{
|
||||||
NODE *cref = NEW_CREF(klass);
|
rb_cref_t *cref = (rb_cref_t *)NEW_CREF(klass);
|
||||||
CREF_REFINEMENTS(cref) = Qnil;
|
CREF_REFINEMENTS_SET(cref, Qnil);
|
||||||
CREF_VISI_SET(cref, visi);
|
CREF_VISI_SET(cref, visi);
|
||||||
CREF_NEXT(cref) = prev_cref;
|
CREF_NEXT_SET(cref, prev_cref);
|
||||||
return cref;
|
return cref;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NODE *
|
static rb_cref_t *
|
||||||
vm_cref_new_toplevel(rb_thread_t *th)
|
vm_cref_new_toplevel(rb_thread_t *th)
|
||||||
{
|
{
|
||||||
NODE *cref = vm_cref_new(rb_cObject, NOEX_PRIVATE /* toplevel visibility is private */, NULL);
|
rb_cref_t *cref = vm_cref_new(rb_cObject, NOEX_PRIVATE /* toplevel visibility is private */, NULL);
|
||||||
|
|
||||||
if (th->top_wrapper) {
|
if (th->top_wrapper) {
|
||||||
cref = vm_cref_new(th->top_wrapper, NOEX_PRIVATE, cref);
|
cref = vm_cref_new(th->top_wrapper, NOEX_PRIVATE, cref);
|
||||||
|
@ -102,7 +102,7 @@ vm_cref_new_toplevel(rb_thread_t *th)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vm_cref_dump(const char *mesg, const NODE *cref)
|
vm_cref_dump(const char *mesg, const rb_cref_t *cref)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "vm_cref_dump: %s (%p)\n", mesg, cref);
|
fprintf(stderr, "vm_cref_dump: %s (%p)\n", mesg, cref);
|
||||||
|
|
||||||
|
@ -251,7 +251,7 @@ vm_set_top_stack(rb_thread_t *th, VALUE iseqval)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref, rb_block_t *base_block)
|
vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const rb_cref_t *cref, rb_block_t *base_block)
|
||||||
{
|
{
|
||||||
rb_iseq_t *iseq;
|
rb_iseq_t *iseq;
|
||||||
GetISeqPtr(iseqval, iseq);
|
GetISeqPtr(iseqval, iseq);
|
||||||
|
@ -795,7 +795,7 @@ rb_binding_add_dynavars(rb_binding_t *bind, int dyncount, const ID *dynvars)
|
||||||
static inline VALUE
|
static inline VALUE
|
||||||
invoke_block_from_c(rb_thread_t *th, const rb_block_t *block,
|
invoke_block_from_c(rb_thread_t *th, const rb_block_t *block,
|
||||||
VALUE self, int argc, const VALUE *argv,
|
VALUE self, int argc, const VALUE *argv,
|
||||||
const rb_block_t *blockptr, const NODE *cref,
|
const rb_block_t *blockptr, const rb_cref_t *cref,
|
||||||
VALUE defined_class, int splattable)
|
VALUE defined_class, int splattable)
|
||||||
{
|
{
|
||||||
if (SPECIAL_CONST_P(block->iseq)) {
|
if (SPECIAL_CONST_P(block->iseq)) {
|
||||||
|
@ -870,7 +870,7 @@ check_block(rb_thread_t *th)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline VALUE
|
static inline VALUE
|
||||||
vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const NODE *cref)
|
vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const rb_cref_t *cref)
|
||||||
{
|
{
|
||||||
const rb_block_t *blockptr = check_block(th);
|
const rb_block_t *blockptr = check_block(th);
|
||||||
return invoke_block_from_c(th, blockptr, blockptr->self, argc, argv, 0, cref,
|
return invoke_block_from_c(th, blockptr, blockptr->self, argc, argv, 0, cref,
|
||||||
|
@ -1039,7 +1039,7 @@ rb_sourceline(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NODE *
|
rb_cref_t *
|
||||||
rb_vm_cref(void)
|
rb_vm_cref(void)
|
||||||
{
|
{
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
|
@ -1052,12 +1052,12 @@ rb_vm_cref(void)
|
||||||
return rb_vm_get_cref(cfp->ep);
|
return rb_vm_get_cref(cfp->ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
const NODE *
|
const rb_cref_t *
|
||||||
rb_vm_cref_in_context(VALUE self, VALUE cbase)
|
rb_vm_cref_in_context(VALUE self, VALUE cbase)
|
||||||
{
|
{
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
|
const rb_control_frame_t *cfp = rb_vm_get_ruby_level_next_cfp(th, th->cfp);
|
||||||
const NODE *cref;
|
const rb_cref_t *cref;
|
||||||
if (cfp->self != self) return NULL;
|
if (cfp->self != self) return NULL;
|
||||||
cref = rb_vm_get_cref(cfp->ep);
|
cref = rb_vm_get_cref(cfp->ep);
|
||||||
if (CREF_CLASS(cref) != cbase) return NULL;
|
if (CREF_CLASS(cref) != cbase) return NULL;
|
||||||
|
@ -1066,7 +1066,7 @@ rb_vm_cref_in_context(VALUE self, VALUE cbase)
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
void
|
void
|
||||||
debug_cref(NODE *cref)
|
debug_cref(rb_cref_t *cref)
|
||||||
{
|
{
|
||||||
while (cref) {
|
while (cref) {
|
||||||
dp(CREF_CLASS(cref));
|
dp(CREF_CLASS(cref));
|
||||||
|
@ -2264,7 +2264,7 @@ rb_thread_alloc(VALUE klass)
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval,
|
vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval,
|
||||||
rb_num_t is_singleton, NODE *cref)
|
rb_num_t is_singleton, rb_cref_t *cref)
|
||||||
{
|
{
|
||||||
VALUE klass = CREF_CLASS(cref);
|
VALUE klass = CREF_CLASS(cref);
|
||||||
int noex = CREF_VISI(cref);
|
int noex = CREF_VISI(cref);
|
||||||
|
|
|
@ -117,7 +117,7 @@ typedef struct rb_compile_option_struct rb_compile_option_t;
|
||||||
|
|
||||||
struct iseq_inline_cache_entry {
|
struct iseq_inline_cache_entry {
|
||||||
rb_serial_t ic_serial;
|
rb_serial_t ic_serial;
|
||||||
NODE *ic_cref;
|
rb_cref_t *ic_cref;
|
||||||
union {
|
union {
|
||||||
size_t index;
|
size_t index;
|
||||||
VALUE value;
|
VALUE value;
|
||||||
|
@ -1000,7 +1000,7 @@ void rb_gc_mark_machine_stack(rb_thread_t *th);
|
||||||
|
|
||||||
int rb_autoloading_value(VALUE mod, ID id, VALUE* value);
|
int rb_autoloading_value(VALUE mod, ID id, VALUE* value);
|
||||||
|
|
||||||
void rb_vm_rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr);
|
void rb_vm_rewrite_cref_stack(rb_cref_t *node, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr);
|
||||||
|
|
||||||
#define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
|
#define sysstack_error GET_VM()->special_exceptions[ruby_error_sysstack]
|
||||||
|
|
||||||
|
|
21
vm_eval.c
21
vm_eval.c
|
@ -16,12 +16,11 @@ struct local_var_list {
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status);
|
static inline VALUE method_missing(VALUE obj, ID id, int argc, const VALUE *argv, int call_status);
|
||||||
static inline VALUE vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const NODE *cref);
|
static inline VALUE vm_yield_with_cref(rb_thread_t *th, int argc, const VALUE *argv, const rb_cref_t *cref);
|
||||||
static inline VALUE vm_yield(rb_thread_t *th, int argc, const VALUE *argv);
|
static inline VALUE vm_yield(rb_thread_t *th, int argc, const VALUE *argv);
|
||||||
static inline VALUE vm_yield_with_block(rb_thread_t *th, int argc, const VALUE *argv, const rb_block_t *blockargptr);
|
static inline VALUE vm_yield_with_block(rb_thread_t *th, int argc, const VALUE *argv, const rb_block_t *blockargptr);
|
||||||
static NODE *vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr);
|
|
||||||
static VALUE vm_exec(rb_thread_t *th);
|
static VALUE vm_exec(rb_thread_t *th);
|
||||||
static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref, rb_block_t *base_block);
|
static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const rb_cref_t *cref, rb_block_t *base_block);
|
||||||
static int vm_collect_local_variables_in_heap(rb_thread_t *th, const VALUE *dfp, const struct local_var_list *vars);
|
static int vm_collect_local_variables_in_heap(rb_thread_t *th, const VALUE *dfp, const struct local_var_list *vars);
|
||||||
|
|
||||||
static VALUE rb_eUncaughtThrow;
|
static VALUE rb_eUncaughtThrow;
|
||||||
|
@ -1229,7 +1228,7 @@ rb_each(VALUE obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE
|
static VALUE
|
||||||
eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg, volatile VALUE file, volatile int line)
|
eval_string_with_cref(VALUE self, VALUE src, VALUE scope, rb_cref_t *const cref_arg, volatile VALUE file, volatile int line)
|
||||||
{
|
{
|
||||||
int state;
|
int state;
|
||||||
VALUE result = Qundef;
|
VALUE result = Qundef;
|
||||||
|
@ -1239,7 +1238,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg,
|
||||||
rb_block_t block, *base_block;
|
rb_block_t block, *base_block;
|
||||||
volatile int parse_in_eval;
|
volatile int parse_in_eval;
|
||||||
volatile int mild_compile_error;
|
volatile int mild_compile_error;
|
||||||
NODE *orig_cref;
|
rb_cref_t *orig_cref;
|
||||||
VALUE crefval;
|
VALUE crefval;
|
||||||
|
|
||||||
if (file == 0) {
|
if (file == 0) {
|
||||||
|
@ -1251,7 +1250,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg,
|
||||||
mild_compile_error = th->mild_compile_error;
|
mild_compile_error = th->mild_compile_error;
|
||||||
TH_PUSH_TAG(th);
|
TH_PUSH_TAG(th);
|
||||||
if ((state = TH_EXEC_TAG()) == 0) {
|
if ((state = TH_EXEC_TAG()) == 0) {
|
||||||
NODE *cref = cref_arg;
|
rb_cref_t *cref = cref_arg;
|
||||||
rb_binding_t *bind = 0;
|
rb_binding_t *bind = 0;
|
||||||
rb_iseq_t *iseq;
|
rb_iseq_t *iseq;
|
||||||
volatile VALUE iseqval;
|
volatile VALUE iseqval;
|
||||||
|
@ -1308,7 +1307,7 @@ eval_string_with_cref(VALUE self, VALUE src, VALUE scope, NODE *const cref_arg,
|
||||||
if (!cref && base_block->iseq) {
|
if (!cref && base_block->iseq) {
|
||||||
if (NIL_P(scope)) {
|
if (NIL_P(scope)) {
|
||||||
orig_cref = rb_vm_get_cref(base_block->ep);
|
orig_cref = rb_vm_get_cref(base_block->ep);
|
||||||
cref = NEW_CREF(Qnil);
|
cref = (rb_cref_t *)NEW_CREF(Qnil);
|
||||||
crefval = (VALUE) cref;
|
crefval = (VALUE) cref;
|
||||||
COPY_CREF(cref, orig_cref);
|
COPY_CREF(cref, orig_cref);
|
||||||
}
|
}
|
||||||
|
@ -1559,7 +1558,7 @@ yield_under(VALUE under, VALUE self, VALUE values)
|
||||||
{
|
{
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
rb_block_t block, *blockptr;
|
rb_block_t block, *blockptr;
|
||||||
NODE *cref;
|
rb_cref_t *cref;
|
||||||
|
|
||||||
if ((blockptr = VM_CF_BLOCK_PTR(th->cfp)) != 0) {
|
if ((blockptr = VM_CF_BLOCK_PTR(th->cfp)) != 0) {
|
||||||
block = *blockptr;
|
block = *blockptr;
|
||||||
|
@ -1582,7 +1581,7 @@ rb_yield_refine_block(VALUE refinement, VALUE refinements)
|
||||||
{
|
{
|
||||||
rb_thread_t *th = GET_THREAD();
|
rb_thread_t *th = GET_THREAD();
|
||||||
rb_block_t block, *blockptr;
|
rb_block_t block, *blockptr;
|
||||||
NODE *cref;
|
rb_cref_t *cref;
|
||||||
|
|
||||||
if ((blockptr = VM_CF_BLOCK_PTR(th->cfp)) != 0) {
|
if ((blockptr = VM_CF_BLOCK_PTR(th->cfp)) != 0) {
|
||||||
block = *blockptr;
|
block = *blockptr;
|
||||||
|
@ -1591,7 +1590,7 @@ rb_yield_refine_block(VALUE refinement, VALUE refinements)
|
||||||
}
|
}
|
||||||
cref = vm_cref_push(th, refinement, NOEX_PUBLIC, blockptr);
|
cref = vm_cref_push(th, refinement, NOEX_PUBLIC, blockptr);
|
||||||
CREF_PUSHED_BY_EVAL_SET(cref);
|
CREF_PUSHED_BY_EVAL_SET(cref);
|
||||||
RB_OBJ_WRITE(cref, &CREF_REFINEMENTS(cref), refinements);
|
CREF_REFINEMENTS_SET(cref, refinements);
|
||||||
|
|
||||||
return vm_yield_with_cref(th, 0, NULL, cref);
|
return vm_yield_with_cref(th, 0, NULL, cref);
|
||||||
}
|
}
|
||||||
|
@ -1600,7 +1599,7 @@ rb_yield_refine_block(VALUE refinement, VALUE refinements)
|
||||||
static VALUE
|
static VALUE
|
||||||
eval_under(VALUE under, VALUE self, VALUE src, VALUE file, int line)
|
eval_under(VALUE under, VALUE self, VALUE src, VALUE file, int line)
|
||||||
{
|
{
|
||||||
NODE *cref = vm_cref_push(GET_THREAD(), under, NOEX_PUBLIC, NULL);
|
rb_cref_t *cref = vm_cref_push(GET_THREAD(), under, NOEX_PUBLIC, NULL);
|
||||||
|
|
||||||
if (SPECIAL_CONST_P(self) && !NIL_P(under)) {
|
if (SPECIAL_CONST_P(self) && !NIL_P(under)) {
|
||||||
CREF_PUSHED_BY_EVAL_SET(cref);
|
CREF_PUSHED_BY_EVAL_SET(cref);
|
||||||
|
|
|
@ -46,7 +46,7 @@ vm_push_frame(rb_thread_t *th,
|
||||||
VALUE self,
|
VALUE self,
|
||||||
VALUE klass,
|
VALUE klass,
|
||||||
VALUE specval,
|
VALUE specval,
|
||||||
const NODE *cref,
|
const rb_cref_t *cref,
|
||||||
const VALUE *pc,
|
const VALUE *pc,
|
||||||
VALUE *sp,
|
VALUE *sp,
|
||||||
int local_size,
|
int local_size,
|
||||||
|
@ -194,7 +194,7 @@ lep_svar_set(rb_thread_t *th, VALUE *lep, rb_num_t key, VALUE val)
|
||||||
svar->nd_reserved = Qfalse;
|
svar->nd_reserved = Qfalse;
|
||||||
}
|
}
|
||||||
else if (nd_type(svar) == NODE_CREF) {
|
else if (nd_type(svar) == NODE_CREF) {
|
||||||
NODE *cref = svar;
|
const rb_cref_t *cref = (rb_cref_t *)svar;
|
||||||
svar = *svar_place = NEW_IF(Qnil, Qnil, Qnil);
|
svar = *svar_place = NEW_IF(Qnil, Qnil, Qnil);
|
||||||
svar->nd_reserved = (VALUE)cref;
|
svar->nd_reserved = (VALUE)cref;
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ vm_getspecial(rb_thread_t *th, VALUE *lep, rb_num_t key, rb_num_t type)
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NODE *
|
static rb_cref_t *
|
||||||
ep_cref(const VALUE *ep)
|
ep_cref(const VALUE *ep)
|
||||||
{
|
{
|
||||||
const VALUE svar = ep[-1];
|
const VALUE svar = ep[-1];
|
||||||
|
@ -262,29 +262,29 @@ ep_cref(const VALUE *ep)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
else if (nd_type(svar) == NODE_CREF) {
|
else if (nd_type(svar) == NODE_CREF) {
|
||||||
return (NODE *)svar;
|
return (rb_cref_t *)svar;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return (NODE *)((NODE *)svar)->nd_reserved;
|
return (rb_cref_t *)((NODE *)svar)->nd_reserved;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static NODE *
|
static rb_cref_t *
|
||||||
vm_get_cref0(const VALUE *ep)
|
vm_get_cref0(const VALUE *ep)
|
||||||
{
|
{
|
||||||
while (!VM_EP_LEP_P(ep)) {
|
while (!VM_EP_LEP_P(ep)) {
|
||||||
if (ep[-1]) {
|
if (ep[-1]) {
|
||||||
return (NODE *)ep[-1];
|
return (rb_cref_t *)ep[-1];
|
||||||
}
|
}
|
||||||
ep = VM_EP_PREV_EP(ep);
|
ep = VM_EP_PREV_EP(ep);
|
||||||
}
|
}
|
||||||
return ep_cref(ep);
|
return ep_cref(ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
NODE *
|
rb_cref_t *
|
||||||
rb_vm_get_cref(const VALUE *ep)
|
rb_vm_get_cref(const VALUE *ep)
|
||||||
{
|
{
|
||||||
NODE *cref = vm_get_cref0(ep);
|
rb_cref_t *cref = vm_get_cref0(ep);
|
||||||
|
|
||||||
if (cref == 0) {
|
if (cref == 0) {
|
||||||
rb_bug("rb_vm_get_cref: unreachable");
|
rb_bug("rb_vm_get_cref: unreachable");
|
||||||
|
@ -294,32 +294,32 @@ rb_vm_get_cref(const VALUE *ep)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_vm_rewrite_cref_stack(NODE *node, VALUE old_klass, VALUE new_klass, NODE **new_cref_ptr)
|
rb_vm_rewrite_cref_stack(rb_cref_t *node, VALUE old_klass, VALUE new_klass, rb_cref_t **new_cref_ptr)
|
||||||
{
|
{
|
||||||
NODE *new_node;
|
rb_cref_t *new_node;
|
||||||
|
|
||||||
while (node) {
|
while (node) {
|
||||||
if (CREF_CLASS(node) == old_klass) {
|
if (CREF_CLASS(node) == old_klass) {
|
||||||
new_node = NEW_CREF(new_klass);
|
new_node = (rb_cref_t *)NEW_CREF(new_klass);
|
||||||
COPY_CREF_OMOD(new_node, node);
|
COPY_CREF_OMOD(new_node, node);
|
||||||
RB_OBJ_WRITE(new_node, &CREF_NEXT(new_node), CREF_NEXT(node));
|
CREF_NEXT_SET(new_node, CREF_NEXT(node));
|
||||||
*new_cref_ptr = new_node;
|
*new_cref_ptr = new_node;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
new_node = NEW_CREF(CREF_CLASS(node));
|
new_node = (rb_cref_t *)NEW_CREF(CREF_CLASS(node));
|
||||||
COPY_CREF_OMOD(new_node, node);
|
COPY_CREF_OMOD(new_node, node);
|
||||||
node = CREF_NEXT(node);
|
node = CREF_NEXT(node);
|
||||||
*new_cref_ptr = new_node;
|
*new_cref_ptr = new_node;
|
||||||
new_cref_ptr = &CREF_NEXT(new_node);
|
new_cref_ptr = &new_node->next;
|
||||||
}
|
}
|
||||||
*new_cref_ptr = NULL;
|
*new_cref_ptr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NODE *
|
static rb_cref_t *
|
||||||
vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr)
|
vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr)
|
||||||
{
|
{
|
||||||
NODE *prev_cref = NULL;
|
const rb_cref_t *prev_cref = NULL;
|
||||||
NODE *cref = NULL;
|
rb_cref_t *cref = NULL;
|
||||||
|
|
||||||
if (blockptr) {
|
if (blockptr) {
|
||||||
prev_cref = vm_get_cref0(blockptr->ep);
|
prev_cref = vm_get_cref0(blockptr->ep);
|
||||||
|
@ -345,7 +345,7 @@ vm_cref_push(rb_thread_t *th, VALUE klass, int noex, rb_block_t *blockptr)
|
||||||
static inline VALUE
|
static inline VALUE
|
||||||
vm_get_cbase(const VALUE *ep)
|
vm_get_cbase(const VALUE *ep)
|
||||||
{
|
{
|
||||||
NODE *cref = rb_vm_get_cref(ep);
|
const rb_cref_t *cref = rb_vm_get_cref(ep);
|
||||||
VALUE klass = Qundef;
|
VALUE klass = Qundef;
|
||||||
|
|
||||||
while (cref) {
|
while (cref) {
|
||||||
|
@ -361,7 +361,7 @@ vm_get_cbase(const VALUE *ep)
|
||||||
static inline VALUE
|
static inline VALUE
|
||||||
vm_get_const_base(const VALUE *ep)
|
vm_get_const_base(const VALUE *ep)
|
||||||
{
|
{
|
||||||
NODE *cref = rb_vm_get_cref(ep);
|
const rb_cref_t *cref = rb_vm_get_cref(ep);
|
||||||
VALUE klass = Qundef;
|
VALUE klass = Qundef;
|
||||||
|
|
||||||
while (cref) {
|
while (cref) {
|
||||||
|
@ -407,8 +407,8 @@ vm_get_ev_const(rb_thread_t *th, VALUE orig_klass, ID id, int is_defined)
|
||||||
|
|
||||||
if (orig_klass == Qnil) {
|
if (orig_klass == Qnil) {
|
||||||
/* in current lexical scope */
|
/* in current lexical scope */
|
||||||
const NODE *root_cref = rb_vm_get_cref(th->cfp->ep);
|
const rb_cref_t *root_cref = rb_vm_get_cref(th->cfp->ep);
|
||||||
const NODE *cref;
|
const rb_cref_t *cref;
|
||||||
VALUE klass = orig_klass;
|
VALUE klass = orig_klass;
|
||||||
|
|
||||||
while (root_cref && CREF_PUSHED_BY_EVAL(root_cref)) {
|
while (root_cref && CREF_PUSHED_BY_EVAL(root_cref)) {
|
||||||
|
@ -477,7 +477,7 @@ vm_get_ev_const(rb_thread_t *th, VALUE orig_klass, ID id, int is_defined)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline VALUE
|
static inline VALUE
|
||||||
vm_get_cvar_base(NODE *cref, rb_control_frame_t *cfp)
|
vm_get_cvar_base(const rb_cref_t *cref, rb_control_frame_t *cfp)
|
||||||
{
|
{
|
||||||
VALUE klass;
|
VALUE klass;
|
||||||
|
|
||||||
|
@ -1784,7 +1784,7 @@ vm_call_method(rb_thread_t *th, rb_control_frame_t *cfp, rb_call_info_t *ci)
|
||||||
case VM_METHOD_TYPE_UNDEF:
|
case VM_METHOD_TYPE_UNDEF:
|
||||||
break;
|
break;
|
||||||
case VM_METHOD_TYPE_REFINED:{
|
case VM_METHOD_TYPE_REFINED:{
|
||||||
NODE *cref = rb_vm_get_cref(cfp->ep);
|
const rb_cref_t *cref = rb_vm_get_cref(cfp->ep);
|
||||||
VALUE refinements = cref ? CREF_REFINEMENTS(cref) : Qnil;
|
VALUE refinements = cref ? CREF_REFINEMENTS(cref) : Qnil;
|
||||||
VALUE refinement, defined_class;
|
VALUE refinement, defined_class;
|
||||||
rb_method_entry_t *me;
|
rb_method_entry_t *me;
|
||||||
|
|
|
@ -146,7 +146,7 @@ enum vm_regan_acttype {
|
||||||
/**********************************************************/
|
/**********************************************************/
|
||||||
|
|
||||||
#define COPY_CREF_OMOD(c1, c2) do { \
|
#define COPY_CREF_OMOD(c1, c2) do { \
|
||||||
RB_OBJ_WRITE((c1), &CREF_REFINEMENTS(c1), CREF_REFINEMENTS(c2)); \
|
CREF_REFINEMENTS_SET(c1, CREF_REFINEMENTS(c2)); \
|
||||||
if (!NIL_P(CREF_REFINEMENTS(c2))) { \
|
if (!NIL_P(CREF_REFINEMENTS(c2))) { \
|
||||||
CREF_OMOD_SHARED_SET(c1); \
|
CREF_OMOD_SHARED_SET(c1); \
|
||||||
CREF_OMOD_SHARED_SET(c2); \
|
CREF_OMOD_SHARED_SET(c2); \
|
||||||
|
@ -154,11 +154,11 @@ enum vm_regan_acttype {
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define COPY_CREF(c1, c2) do { \
|
#define COPY_CREF(c1, c2) do { \
|
||||||
NODE *__tmp_c2 = (c2); \
|
rb_cref_t *__tmp_c2 = (c2); \
|
||||||
COPY_CREF_OMOD(c1, __tmp_c2); \
|
COPY_CREF_OMOD((c1), __tmp_c2); \
|
||||||
RB_OBJ_WRITE((c1), &CREF_CLASS(c1), CREF_CLASS(__tmp_c2)); \
|
CREF_CLASS_SET((c1), CREF_CLASS(__tmp_c2));\
|
||||||
CREF_VISI_SET((c1), CREF_VISI(__tmp_c2));\
|
CREF_VISI_SET((c1), CREF_VISI(__tmp_c2));\
|
||||||
RB_OBJ_WRITE((c1), &CREF_NEXT(c1), CREF_NEXT(__tmp_c2)); \
|
CREF_NEXT_SET((c1), CREF_NEXT(__tmp_c2));\
|
||||||
if (CREF_PUSHED_BY_EVAL(__tmp_c2)) { \
|
if (CREF_PUSHED_BY_EVAL(__tmp_c2)) { \
|
||||||
CREF_PUSHED_BY_EVAL_SET(c1); \
|
CREF_PUSHED_BY_EVAL_SET(c1); \
|
||||||
} \
|
} \
|
||||||
|
|
|
@ -447,7 +447,7 @@ setup_method_cfunc_struct(rb_method_cfunc_t *cfunc, VALUE (*func)(), int argc)
|
||||||
}
|
}
|
||||||
|
|
||||||
rb_method_entry_t *
|
rb_method_entry_t *
|
||||||
rb_add_method0(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_flag_t noex, NODE *cref)
|
rb_add_method0(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_flag_t noex, rb_cref_t *cref)
|
||||||
{
|
{
|
||||||
rb_thread_t *th;
|
rb_thread_t *th;
|
||||||
rb_control_frame_t *cfp;
|
rb_control_frame_t *cfp;
|
||||||
|
@ -471,7 +471,7 @@ rb_add_method0(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VM_METHOD_TYPE_ISEQ: {
|
case VM_METHOD_TYPE_ISEQ: {
|
||||||
rb_iseq_t *iseq = (rb_iseq_t *)opts;
|
rb_iseq_t *iseq = (rb_iseq_t *)opts;
|
||||||
NODE *private_cref;
|
rb_cref_t *private_cref;
|
||||||
|
|
||||||
*(rb_iseq_t **)&def->body.iseq_body.iseq = iseq;
|
*(rb_iseq_t **)&def->body.iseq_body.iseq = iseq;
|
||||||
RB_OBJ_WRITTEN(klass, Qundef, iseq->self); /* should be set iseq before newobj */
|
RB_OBJ_WRITTEN(klass, Qundef, iseq->self); /* should be set iseq before newobj */
|
||||||
|
@ -531,7 +531,7 @@ rb_add_method(VALUE klass, ID mid, rb_method_type_t type, void *opts, rb_method_
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
rb_add_method_iseq(VALUE klass, ID mid, rb_iseq_t *iseq, NODE *cref, rb_method_flag_t noex)
|
rb_add_method_iseq(VALUE klass, ID mid, rb_iseq_t *iseq, rb_cref_t *cref, rb_method_flag_t noex)
|
||||||
{
|
{
|
||||||
rb_add_method0(klass, mid, VM_METHOD_TYPE_ISEQ, iseq, noex, cref);
|
rb_add_method0(klass, mid, VM_METHOD_TYPE_ISEQ, iseq, noex, cref);
|
||||||
}
|
}
|
||||||
|
@ -743,7 +743,7 @@ rb_method_entry_with_refinements(VALUE klass, ID id,
|
||||||
rb_method_entry_t *me = rb_method_entry(klass, id, &defined_class);
|
rb_method_entry_t *me = rb_method_entry(klass, id, &defined_class);
|
||||||
|
|
||||||
if (me && me->def->type == VM_METHOD_TYPE_REFINED) {
|
if (me && me->def->type == VM_METHOD_TYPE_REFINED) {
|
||||||
NODE *cref = rb_vm_cref();
|
const rb_cref_t *cref = rb_vm_cref();
|
||||||
VALUE refinements = cref ? CREF_REFINEMENTS(cref) : Qnil;
|
VALUE refinements = cref ? CREF_REFINEMENTS(cref) : Qnil;
|
||||||
|
|
||||||
me = rb_resolve_refined_method(refinements, me, &defined_class);
|
me = rb_resolve_refined_method(refinements, me, &defined_class);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue