зеркало из https://github.com/github/ruby.git
* insns.def: add a "putcbase" instruction.
* compile.c, insns.def: fix to use putcbase instruction for class search. Qundef should not be used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16411 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
86294fad68
Коммит
5e4edb43a2
|
@ -1,3 +1,10 @@
|
||||||
|
Wed May 14 11:29:06 2008 Koichi Sasada <ko1@atdot.net>
|
||||||
|
|
||||||
|
* insns.def: add a "putcbase" instruction.
|
||||||
|
|
||||||
|
* compile.c, insns.def: fix to use putcbase instruction for
|
||||||
|
class search. Qundef should not be used.
|
||||||
|
|
||||||
Wed May 14 07:49:35 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
Wed May 14 07:49:35 2008 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
* eval.c (rb_call0): defer calling of rb_frame_self() until it
|
* eval.c (rb_call0): defer calling of rb_frame_self() until it
|
||||||
|
|
16
compile.c
16
compile.c
|
@ -2280,22 +2280,24 @@ compile_colon2(rb_iseq_t *iseq, NODE * node,
|
||||||
return COMPILE_OK;
|
return COMPILE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static VALUE
|
||||||
compile_cpath(LINK_ANCHOR *ret, rb_iseq_t *iseq, NODE *cpath)
|
compile_cpath(LINK_ANCHOR *ret, rb_iseq_t *iseq, NODE *cpath)
|
||||||
{
|
{
|
||||||
if (nd_type(cpath) == NODE_COLON3) {
|
if (nd_type(cpath) == NODE_COLON3) {
|
||||||
/* toplevel class ::Foo */
|
/* toplevel class ::Foo */
|
||||||
ADD_INSN1(ret, nd_line(cpath), putobject, rb_cObject);
|
ADD_INSN1(ret, nd_line(cpath), putobject, rb_cObject);
|
||||||
|
return Qfalse;
|
||||||
}
|
}
|
||||||
else if (cpath->nd_head) {
|
else if (cpath->nd_head) {
|
||||||
/* Bar::Foo */
|
/* Bar::Foo */
|
||||||
COMPILE(ret, "nd_else->nd_head", cpath->nd_head);
|
COMPILE(ret, "nd_else->nd_head", cpath->nd_head);
|
||||||
|
return Qfalse;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* class at cbase Foo */
|
/* class at cbase Foo */
|
||||||
ADD_INSN1(ret, nd_line(cpath), putobject, Qundef);
|
ADD_INSN(ret, nd_line(cpath), putcbase);
|
||||||
|
return Qtrue;
|
||||||
}
|
}
|
||||||
return COMPILE_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -3438,14 +3440,12 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (node->nd_vid) {
|
if (node->nd_vid) {
|
||||||
ADD_INSN1(ret, nd_line(node), putobject, Qundef);
|
ADD_INSN (ret, nd_line(node), putcbase);
|
||||||
ADD_INSN1(ret, nd_line(node), setconstant,
|
ADD_INSN1(ret, nd_line(node), setconstant, ID2SYM(node->nd_vid));
|
||||||
ID2SYM(node->nd_vid));
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
compile_cpath(ret, iseq, node->nd_else);
|
compile_cpath(ret, iseq, node->nd_else);
|
||||||
ADD_INSN1(ret, nd_line(node), setconstant,
|
ADD_INSN1(ret, nd_line(node), setconstant, ID2SYM(node->nd_else->nd_mid));
|
||||||
ID2SYM(node->nd_else->nd_mid));
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
40
insns.def
40
insns.def
|
@ -237,18 +237,11 @@ getconstant
|
||||||
DEFINE_INSN
|
DEFINE_INSN
|
||||||
setconstant
|
setconstant
|
||||||
(ID id)
|
(ID id)
|
||||||
(VALUE val, VALUE klass)
|
(VALUE val, VALUE cbase)
|
||||||
()
|
()
|
||||||
{
|
{
|
||||||
if (klass == Qundef) {
|
vm_check_if_namespace(cbase);
|
||||||
klass = vm_get_cbase(th);
|
rb_const_set(cbase, id, val);
|
||||||
if (NIL_P(klass)) {
|
|
||||||
rb_raise(rb_eTypeError, "no class/module to define constant");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vm_check_if_namespace(klass);
|
|
||||||
rb_const_set(klass, id, val);
|
|
||||||
INC_VM_STATE_VERSION();
|
INC_VM_STATE_VERSION();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,6 +306,20 @@ putself
|
||||||
val = GET_SELF();
|
val = GET_SELF();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@c put
|
||||||
|
@e put cbase.
|
||||||
|
@j スタックに cbase をプッシュする。
|
||||||
|
*/
|
||||||
|
DEFINE_INSN
|
||||||
|
putcbase
|
||||||
|
()
|
||||||
|
()
|
||||||
|
(VALUE val)
|
||||||
|
{
|
||||||
|
val = vm_get_cbase(th);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@c put
|
@c put
|
||||||
@e put some object.
|
@e put some object.
|
||||||
|
@ -929,13 +936,6 @@ defineclass
|
||||||
super = rb_cObject;
|
super = rb_cObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cbase == Qundef) {
|
|
||||||
cbase = vm_get_cbase(th);
|
|
||||||
if (NIL_P(cbase)) {
|
|
||||||
rb_raise(rb_eTypeError, "no class/module to define constant");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vm_check_if_namespace(cbase);
|
vm_check_if_namespace(cbase);
|
||||||
|
|
||||||
/* find klass */
|
/* find klass */
|
||||||
|
@ -972,12 +972,6 @@ defineclass
|
||||||
case 2:
|
case 2:
|
||||||
/* val is dummy. classdef returns class scope value */
|
/* val is dummy. classdef returns class scope value */
|
||||||
/* super is dummy */
|
/* super is dummy */
|
||||||
if (cbase == Qundef) {
|
|
||||||
cbase = vm_get_cbase(th);
|
|
||||||
if (NIL_P(cbase)) {
|
|
||||||
rb_raise(rb_eTypeError, "no class/module to define constant");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vm_check_if_namespace(cbase);
|
vm_check_if_namespace(cbase);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче