mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* parse.y, compile.c, gc.c, insns.def, intern.h, iseq.c, node.h,
object.c, string.c, variable.c, vm_macro.def: revert private instance variable feature, which is postponed until next major release. * marshal.c: TYPE_SYMBOL2 removed; MARSHAL_MINOR reverted back to 8th version. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3600c7ef8f
commit
b83ed6d1bd
13 changed files with 25 additions and 160 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Fri Feb 23 11:41:21 2007 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* parse.y, compile.c, gc.c, insns.def, intern.h, iseq.c, node.h,
|
||||
object.c, string.c, variable.c, vm_macro.def: revert private
|
||||
instance variable feature, which is postponed until next major
|
||||
release.
|
||||
|
||||
* marshal.c: TYPE_SYMBOL2 removed; MARSHAL_MINOR reverted back to
|
||||
8th version.
|
||||
|
||||
Fri Feb 23 10:53:21 2007 Shugo Maeda <shugo@ruby-lang.org>
|
||||
|
||||
* thread_pthread.ci (native_mutex_lock): do not call
|
||||
|
|
19
compile.c
19
compile.c
|
@ -2343,11 +2343,6 @@ defined_expr(rb_iseq_t *iseq, LINK_ANCHOR *ret,
|
|||
ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_IVAR),
|
||||
ID2SYM(node->nd_vid), needstr);
|
||||
return 1;
|
||||
case NODE_IVAR2:
|
||||
ADD_INSN(ret, nd_line(node), putnil);
|
||||
ADD_INSN3(ret, nd_line(node), defined, INT2FIX(DEFINED_IVAR2),
|
||||
ID2SYM(node->nd_vid), needstr);
|
||||
return 1;
|
||||
|
||||
case NODE_GVAR:
|
||||
ADD_INSN(ret, nd_line(node), putnil);
|
||||
|
@ -3321,13 +3316,12 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
}
|
||||
case NODE_IASGN:
|
||||
case NODE_IASGN2:{
|
||||
int is_local = (nd_type(node) == NODE_IASGN2) ? 1 : 0;
|
||||
COMPILE(ret, "lvalue", node->nd_value);
|
||||
if (!poped) {
|
||||
ADD_INSN(ret, nd_line(node), dup);
|
||||
}
|
||||
ADD_INSN2(ret, nd_line(node), setinstancevariable,
|
||||
ID2SYM(node->nd_vid), INT2FIX(is_local));
|
||||
ADD_INSN1(ret, nd_line(node), setinstancevariable,
|
||||
ID2SYM(node->nd_vid));
|
||||
break;
|
||||
}
|
||||
case NODE_CDECL:{
|
||||
|
@ -3898,14 +3892,11 @@ iseq_compile_each(rb_iseq_t *iseq, LINK_ANCHOR *ret, NODE * node, int poped)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case NODE_IVAR:
|
||||
case NODE_IVAR2:{
|
||||
int is_local = (nd_type(node) == NODE_IVAR2) ? 1 : 0;
|
||||
|
||||
case NODE_IVAR:{
|
||||
debugi("nd_vid", node->nd_vid);
|
||||
if (!poped) {
|
||||
ADD_INSN2(ret, nd_line(node), getinstancevariable,
|
||||
ID2SYM(node->nd_vid), INT2FIX(is_local));
|
||||
ADD_INSN1(ret, nd_line(node), getinstancevariable,
|
||||
ID2SYM(node->nd_vid));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
1
gc.c
1
gc.c
|
@ -934,7 +934,6 @@ gc_mark_children(VALUE ptr, int lev)
|
|||
case NODE_LVAR:
|
||||
case NODE_DVAR:
|
||||
case NODE_IVAR:
|
||||
case NODE_IVAR2:
|
||||
case NODE_CVAR:
|
||||
case NODE_NTH_REF:
|
||||
case NODE_BACK_REF:
|
||||
|
|
13
insns.def
13
insns.def
|
@ -181,13 +181,10 @@ setdynamic
|
|||
*/
|
||||
DEFINE_INSN
|
||||
getinstancevariable
|
||||
(ID id, num_t is_local)
|
||||
(ID id)
|
||||
()
|
||||
(VALUE val)
|
||||
{
|
||||
if (is_local) {
|
||||
id = rb_compose_ivar2(id, eval_get_cvar_base(th, GET_ISEQ()));
|
||||
}
|
||||
val = rb_ivar_get(GET_SELF(), id);
|
||||
}
|
||||
|
||||
|
@ -200,13 +197,10 @@ getinstancevariable
|
|||
*/
|
||||
DEFINE_INSN
|
||||
setinstancevariable
|
||||
(ID id, num_t is_local)
|
||||
(ID id)
|
||||
(VALUE val)
|
||||
()
|
||||
{
|
||||
if (is_local) {
|
||||
id = rb_compose_ivar2(id, eval_get_cvar_base(th, GET_ISEQ()));
|
||||
}
|
||||
rb_ivar_set(GET_SELF(), id, val);
|
||||
}
|
||||
|
||||
|
@ -913,9 +907,6 @@ defined
|
|||
break;
|
||||
case DEFINED_IVAR2:
|
||||
klass = get_cref(GET_ISEQ(), GET_LFP())->nd_clss;
|
||||
if (rb_ivar_defined(GET_SELF(), rb_compose_ivar2(SYM2ID(obj), klass))) {
|
||||
expr_type = "class local instance-variable";
|
||||
}
|
||||
break;
|
||||
case DEFINED_GVAR:
|
||||
if (rb_gvar_defined((struct global_entry *)(obj & ~1))) {
|
||||
|
|
3
intern.h
3
intern.h
|
@ -398,7 +398,6 @@ ID rb_id_attrset(ID);
|
|||
void rb_gc_mark_parser(void);
|
||||
int rb_is_const_id(ID);
|
||||
int rb_is_instance_id(ID);
|
||||
int rb_is_instance2_id(ID);
|
||||
int rb_is_class_id(ID);
|
||||
int rb_is_local_id(ID);
|
||||
int rb_is_junk_id(ID);
|
||||
|
@ -410,8 +409,6 @@ void rb_backref_set(VALUE);
|
|||
VALUE rb_lastline_get(void);
|
||||
void rb_lastline_set(VALUE);
|
||||
VALUE rb_sym_all_symbols(void);
|
||||
ID rb_compose_ivar2(ID, VALUE);
|
||||
ID rb_decompose_ivar2(ID, VALUE*);
|
||||
/* process.c */
|
||||
void rb_last_status_set(int status, rb_pid_t pid);
|
||||
VALUE rb_last_status_get(void);
|
||||
|
|
2
iseq.c
2
iseq.c
|
@ -905,8 +905,6 @@ ruby_node_name(int node)
|
|||
return "NODE_GVAR";
|
||||
case NODE_IVAR:
|
||||
return "NODE_IVAR";
|
||||
case NODE_IVAR2:
|
||||
return "NODE_IVAR2";
|
||||
case NODE_CONST:
|
||||
return "NODE_CONST";
|
||||
case NODE_CVAR:
|
||||
|
|
43
marshal.c
43
marshal.c
|
@ -47,7 +47,7 @@ shortlen(long len, BDIGIT *ds)
|
|||
#endif
|
||||
|
||||
#define MARSHAL_MAJOR 4
|
||||
#define MARSHAL_MINOR 9
|
||||
#define MARSHAL_MINOR 8
|
||||
|
||||
#define TYPE_NIL '0'
|
||||
#define TYPE_TRUE 'T'
|
||||
|
@ -73,7 +73,6 @@ shortlen(long len, BDIGIT *ds)
|
|||
#define TYPE_MODULE 'm'
|
||||
|
||||
#define TYPE_SYMBOL ':'
|
||||
#define TYPE_SYMBOL2 ','
|
||||
#define TYPE_SYMLINK ';'
|
||||
|
||||
#define TYPE_IVAR 'I'
|
||||
|
@ -313,22 +312,9 @@ w_symbol(ID id, struct dump_arg *arg)
|
|||
w_long((long)num, arg);
|
||||
}
|
||||
else {
|
||||
if (rb_is_instance2_id(id)) {
|
||||
VALUE klass;
|
||||
volatile VALUE path;
|
||||
|
||||
id = rb_decompose_ivar2(id, &klass);
|
||||
path = class2path(klass);
|
||||
w_byte(TYPE_SYMBOL2, arg);
|
||||
sym = rb_id2name(id);
|
||||
w_bytes(sym, strlen(sym), arg);
|
||||
w_bytes(RSTRING_PTR(path), RSTRING_LEN(path), arg);
|
||||
}
|
||||
else {
|
||||
sym = rb_id2name(id);
|
||||
w_byte(TYPE_SYMBOL, arg);
|
||||
w_bytes(sym, strlen(sym), arg);
|
||||
}
|
||||
sym = rb_id2name(id);
|
||||
w_byte(TYPE_SYMBOL, arg);
|
||||
w_bytes(sym, strlen(sym), arg);
|
||||
st_add_direct(arg->symbols, id, arg->symbols->num_entries);
|
||||
}
|
||||
}
|
||||
|
@ -882,21 +868,6 @@ r_symreal(struct load_arg *arg)
|
|||
return id;
|
||||
}
|
||||
|
||||
static ID
|
||||
r_symivar2(struct load_arg *arg)
|
||||
{
|
||||
volatile VALUE s = r_bytes(arg);
|
||||
ID id = rb_intern(RSTRING_PTR(s));
|
||||
VALUE klass;
|
||||
|
||||
s = r_bytes(arg);
|
||||
klass = r_entry(path2class(RSTRING_PTR(s)), arg);
|
||||
id = rb_compose_ivar2(id, klass);
|
||||
st_insert(arg->symbols, arg->symbols->num_entries, id);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
static ID
|
||||
r_symbol(struct load_arg *arg)
|
||||
{
|
||||
|
@ -905,8 +876,6 @@ r_symbol(struct load_arg *arg)
|
|||
switch ((type = r_byte(arg))) {
|
||||
case TYPE_SYMBOL:
|
||||
return r_symreal(arg);
|
||||
case TYPE_SYMBOL2:
|
||||
return r_symivar2(arg);
|
||||
case TYPE_SYMLINK:
|
||||
return r_symlink(arg);
|
||||
default:
|
||||
|
@ -1316,10 +1285,6 @@ r_object0(struct load_arg *arg, int *ivp, VALUE extmod)
|
|||
v = ID2SYM(r_symreal(arg));
|
||||
break;
|
||||
|
||||
case TYPE_SYMBOL2:
|
||||
v = ID2SYM(r_symivar2(arg));
|
||||
break;
|
||||
|
||||
case TYPE_SYMLINK:
|
||||
v = ID2SYM(r_symlink(arg));
|
||||
break;
|
||||
|
|
2
node.h
2
node.h
|
@ -71,7 +71,6 @@ enum node_type {
|
|||
NODE_DVAR,
|
||||
NODE_GVAR,
|
||||
NODE_IVAR,
|
||||
NODE_IVAR2,
|
||||
NODE_CONST,
|
||||
NODE_CVAR,
|
||||
NODE_NTH_REF,
|
||||
|
@ -297,7 +296,6 @@ typedef struct RNode {
|
|||
#define NEW_LVAR(v) NEW_NODE(NODE_LVAR,v,0,local_cnt(v))
|
||||
#define NEW_DVAR(v) NEW_NODE(NODE_DVAR,v,0,0)
|
||||
#define NEW_IVAR(v) NEW_NODE(NODE_IVAR,v,0,0)
|
||||
#define NEW_IVAR2(v) NEW_NODE(NODE_IVAR2,v,0,0)
|
||||
#define NEW_CONST(v) NEW_NODE(NODE_CONST,v,0,0)
|
||||
#define NEW_CVAR(v) NEW_NODE(NODE_CVAR,v,0,0)
|
||||
#define NEW_NTH_REF(n) NEW_NODE(NODE_NTH_REF,0,n,local_cnt('~'))
|
||||
|
|
6
object.c
6
object.c
|
@ -1679,7 +1679,7 @@ rb_obj_ivar_get(VALUE obj, VALUE iv)
|
|||
{
|
||||
ID id = rb_to_id(iv);
|
||||
|
||||
if (!rb_is_instance_id(id) && !rb_is_instance2_id(id)) {
|
||||
if (!rb_is_instance_id(id)) {
|
||||
rb_name_error(id, "`%s' is not allowed as an instance variable name", rb_id2name(id));
|
||||
}
|
||||
return rb_ivar_get(obj, id);
|
||||
|
@ -1710,7 +1710,7 @@ rb_obj_ivar_set(VALUE obj, VALUE iv, VALUE val)
|
|||
{
|
||||
ID id = rb_to_id(iv);
|
||||
|
||||
if (!rb_is_instance_id(id) && !rb_is_instance2_id(id)) {
|
||||
if (!rb_is_instance_id(id)) {
|
||||
rb_name_error(id, "`%s' is not allowed as an instance variable name", rb_id2name(id));
|
||||
}
|
||||
return rb_ivar_set(obj, id, val);
|
||||
|
@ -1739,7 +1739,7 @@ rb_obj_ivar_defined(VALUE obj, VALUE iv)
|
|||
{
|
||||
ID id = rb_to_id(iv);
|
||||
|
||||
if (!rb_is_instance_id(id) && !rb_is_instance2_id(id)) {
|
||||
if (!rb_is_instance_id(id)) {
|
||||
rb_name_error(id, "`%s' is not allowed as an instance variable name", rb_id2name(id));
|
||||
}
|
||||
return rb_ivar_defined(obj, id);
|
||||
|
|
50
parse.y
50
parse.y
|
@ -37,7 +37,6 @@
|
|||
#define ID_SCOPE_MASK 0x07
|
||||
#define ID_LOCAL 0x00
|
||||
#define ID_INSTANCE 0x01
|
||||
#define ID_INSTANCE2 0x02
|
||||
#define ID_GLOBAL 0x03
|
||||
#define ID_ATTRSET 0x04
|
||||
#define ID_CONST 0x05
|
||||
|
@ -49,7 +48,6 @@
|
|||
#define is_local_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL)
|
||||
#define is_global_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_GLOBAL)
|
||||
#define is_instance_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_INSTANCE)
|
||||
#define is_instance2_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_INSTANCE2)
|
||||
#define is_attrset_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_ATTRSET)
|
||||
#define is_const_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CONST)
|
||||
#define is_class_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_CLASS)
|
||||
|
@ -7247,9 +7245,6 @@ gettable_gen(struct parser_params *parser, ID id)
|
|||
else if (is_instance_id(id)) {
|
||||
return NEW_IVAR(id);
|
||||
}
|
||||
else if (is_instance2_id(id)) {
|
||||
return NEW_IVAR2(id);
|
||||
}
|
||||
else if (is_const_id(id)) {
|
||||
return NEW_CONST(id);
|
||||
}
|
||||
|
@ -7303,9 +7298,6 @@ assignable_gen(struct parser_params *parser, ID id, NODE *val)
|
|||
else if (is_instance_id(id)) {
|
||||
return NEW_IASGN(id, val);
|
||||
}
|
||||
else if (is_instance2_id(id)) {
|
||||
return NEW_IASGN2(id, val);
|
||||
}
|
||||
else if (is_const_id(id)) {
|
||||
if (in_def || in_single)
|
||||
yyerror("dynamic constant assignment");
|
||||
|
@ -8482,9 +8474,6 @@ rb_intern2(const char *name, long len)
|
|||
m++;
|
||||
id |= ID_CLASS;
|
||||
}
|
||||
else if (name[1] == '_') {
|
||||
id |= ID_INSTANCE2;
|
||||
}
|
||||
else {
|
||||
id |= ID_INSTANCE;
|
||||
}
|
||||
|
@ -8546,38 +8535,6 @@ rb_intern(const char *name)
|
|||
return rb_intern2(name, strlen(name));
|
||||
}
|
||||
|
||||
ID
|
||||
rb_compose_ivar2(ID oid, VALUE klass)
|
||||
{
|
||||
struct ivar2_key key, *kp;
|
||||
ID id;
|
||||
|
||||
key.id = oid;
|
||||
key.klass = klass;
|
||||
if (st_lookup(global_symbols.ivar2_id, (st_data_t)&key, (st_data_t *)&id))
|
||||
return id;
|
||||
|
||||
kp = ALLOC_N(struct ivar2_key, 1);
|
||||
kp->id = oid; kp->klass = klass;
|
||||
id = ID_INSTANCE2;
|
||||
id |= ++global_symbols.last_id << ID_SCOPE_SHIFT;
|
||||
st_add_direct(global_symbols.ivar2_id, (st_data_t)kp, (st_data_t)id);
|
||||
st_add_direct(global_symbols.id_ivar2, (st_data_t)id, (st_data_t)kp);
|
||||
return id;
|
||||
}
|
||||
|
||||
ID
|
||||
rb_decompose_ivar2(ID id, VALUE *klassp)
|
||||
{
|
||||
struct ivar2_key *kp;
|
||||
|
||||
if (!st_lookup(global_symbols.id_ivar2, (st_data_t)id, (st_data_t *)&kp)) {
|
||||
return id;
|
||||
}
|
||||
if (klassp) *klassp = kp->klass;
|
||||
return kp->id;
|
||||
}
|
||||
|
||||
VALUE
|
||||
rb_id2str(ID id)
|
||||
{
|
||||
|
@ -8686,13 +8643,6 @@ rb_is_instance_id(ID id)
|
|||
return Qfalse;
|
||||
}
|
||||
|
||||
int
|
||||
rb_is_instance2_id(ID id)
|
||||
{
|
||||
if (is_instance2_id(id)) return Qtrue;
|
||||
return Qfalse;
|
||||
}
|
||||
|
||||
int
|
||||
rb_is_local_id(ID id)
|
||||
{
|
||||
|
|
28
string.c
28
string.c
|
@ -4685,9 +4685,6 @@ sym_inspect(VALUE sym)
|
|||
VALUE str, klass = Qundef;
|
||||
ID id = SYM2ID(sym);
|
||||
|
||||
if (rb_is_instance2_id(id)) {
|
||||
id = rb_decompose_ivar2(id, &klass);
|
||||
}
|
||||
sym = rb_id2str(id);
|
||||
str = rb_str_new(0, RSTRING_LEN(sym)+1);
|
||||
RSTRING_PTR(str)[0] = ':';
|
||||
|
@ -4721,9 +4718,6 @@ rb_sym_to_s(VALUE sym)
|
|||
{
|
||||
ID id = SYM2ID(sym);
|
||||
|
||||
if (rb_is_instance2_id(id)) {
|
||||
id = rb_decompose_ivar2(id, 0);
|
||||
}
|
||||
return str_new3(rb_cString, rb_id2str(id));
|
||||
}
|
||||
|
||||
|
@ -4876,27 +4870,6 @@ rb_to_id(VALUE name)
|
|||
return id;
|
||||
}
|
||||
|
||||
static VALUE
|
||||
sym_div(VALUE sym, VALUE klass)
|
||||
{
|
||||
ID id = SYM2ID(sym);
|
||||
|
||||
if (!rb_is_instance2_id(id)) {
|
||||
rb_raise(rb_eArgError, "symbol %s should be local instance variable",
|
||||
rb_id2name(id));
|
||||
}
|
||||
switch (TYPE(klass)) {
|
||||
case T_CLASS:
|
||||
case T_MODULE:
|
||||
break;
|
||||
default:
|
||||
rb_check_type(klass, T_CLASS);
|
||||
break;
|
||||
}
|
||||
id = rb_compose_ivar2(id, klass);
|
||||
return ID2SYM(id);
|
||||
}
|
||||
|
||||
/*
|
||||
* A <code>String</code> object holds and manipulates an arbitrary sequence of
|
||||
* bytes, typically representing characters. String objects may be created
|
||||
|
@ -5037,7 +5010,6 @@ Init_String(void)
|
|||
rb_define_singleton_method(rb_cSymbol, "all_symbols", rb_sym_all_symbols, 0); /* in parse.y */
|
||||
rb_define_singleton_method(rb_cSymbol, "intern", rb_sym_s_intern, 1);
|
||||
|
||||
rb_define_method(rb_cSymbol, "/", sym_div, 1);
|
||||
rb_define_method(rb_cSymbol, "==", sym_equal, 1);
|
||||
rb_define_method(rb_cSymbol, "to_i", sym_to_i, 0);
|
||||
rb_define_method(rb_cSymbol, "inspect", sym_inspect, 0);
|
||||
|
|
|
@ -985,7 +985,7 @@ rb_ivar_defined(VALUE obj, ID id)
|
|||
static int
|
||||
ivar_i(ID key, struct global_entry *entry, VALUE ary)
|
||||
{
|
||||
if (rb_is_instance_id(key) || rb_is_instance2_id(key)) {
|
||||
if (rb_is_instance_id(key)) {
|
||||
rb_ary_push(ary, ID2SYM(key));
|
||||
}
|
||||
return ST_CONTINUE;
|
||||
|
|
|
@ -293,12 +293,6 @@ MACRO macro_eval_invoke_method(recv, klass, id, num, mn, blockptr)
|
|||
POP();
|
||||
break;
|
||||
}
|
||||
case NODE_IVAR2:{
|
||||
ID vid = rb_compose_ivar2(node->nd_vid, mn->nd_clss);
|
||||
val = rb_ivar_get(recv, vid);
|
||||
POP();
|
||||
break;
|
||||
}
|
||||
case NODE_BMETHOD:{
|
||||
VALUE *argv = GET_SP() - num;
|
||||
val = th_invoke_bmethod(th, id, node->nd_cval,
|
||||
|
|
Loading…
Reference in a new issue