Skip to content

Commit

Permalink
* parse.y, compile.c, gc.c, insns.def, intern.h, iseq.c, node.h,
Browse files Browse the repository at this point in the history
  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
  • Loading branch information
matz committed Feb 23, 2007
1 parent 3600c7e commit b83ed6d
Show file tree
Hide file tree
Showing 13 changed files with 25 additions and 160 deletions.
10 changes: 10 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Fri Feb 23 11:41:21 2007 Yukihiro Matsumoto <[email protected]>

* 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 <[email protected]>

* thread_pthread.ci (native_mutex_lock): do not call
Expand Down
19 changes: 5 additions & 14 deletions compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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:{
Expand Down Expand Up @@ -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;
}
Expand Down
1 change: 0 additions & 1 deletion gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 2 additions & 11 deletions insns.def
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down Expand Up @@ -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))) {
Expand Down
3 changes: 0 additions & 3 deletions intern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
43 changes: 4 additions & 39 deletions marshal.c
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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);
}
}
Expand Down Expand Up @@ -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)
{
Expand All @@ -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:
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 0 additions & 2 deletions node.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ enum node_type {
NODE_DVAR,
NODE_GVAR,
NODE_IVAR,
NODE_IVAR2,
NODE_CONST,
NODE_CVAR,
NODE_NTH_REF,
Expand Down Expand Up @@ -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('~'))
Expand Down
6 changes: 3 additions & 3 deletions object.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
50 changes: 0 additions & 50 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
{
Expand Down
Loading

0 comments on commit b83ed6d

Please sign in to comment.