ruby-changes:48528
From: mame <ko1@a...>
Date: Sat, 4 Nov 2017 20:37:24 +0900 (JST)
Subject: [ruby-changes:48528] mame:r60643 (trunk): Remove RNODE cast from NODE utility functions
mame 2017-11-04 20:37:19 +0900 (Sat, 04 Nov 2017) New Revision: 60643 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60643 Log: Remove RNODE cast from NODE utility functions Now, casting NODE to VALUE is not recommended. This change requires an explicit cast from VALUE to NODE to use the NODE utility functions such as `nd_type`. Modified files: trunk/compile.c trunk/ext/objspace/objspace_dump.c trunk/node.h Index: compile.c =================================================================== --- compile.c (revision 60642) +++ compile.c (revision 60643) @@ -4227,7 +4227,7 @@ setup_args(rb_iseq_t *iseq, LINK_ANCHOR https://github.com/ruby/ruby/blob/trunk/compile.c#L4227 if (nsplat > 1) { int i; for (i=1; i<nsplat; i++) { - ADD_INSN(args_splat, nd_line(args), concatarray); + ADD_INSN(args_splat, nd_line(RNODE(args)), concatarray); } } Index: ext/objspace/objspace_dump.c =================================================================== --- ext/objspace/objspace_dump.c (revision 60642) +++ ext/objspace/objspace_dump.c (revision 60643) @@ -244,10 +244,6 @@ dump_object(VALUE obj, struct dump_confi https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace_dump.c#L244 dump_append(dc, "}\n"); return; - case T_NODE: - dump_append(dc, ", \"node_type\":\"%s\"", ruby_node_name(nd_type(obj))); - break; - case T_IMEMO: dump_append(dc, ", \"imemo_type\":\"%s\"", imemo_name(imemo_type(obj))); break; Index: node.h =================================================================== --- node.h (revision 60642) +++ node.h (revision 60643) @@ -261,22 +261,22 @@ typedef struct RNode { https://github.com/ruby/ruby/blob/trunk/node.h#L261 #define NODE_TYPESHIFT 8 #define NODE_TYPEMASK (((VALUE)0x7f)<<NODE_TYPESHIFT) -#define nd_type(n) ((int) (((RNODE(n))->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT)) +#define nd_type(n) ((int) (((n)->flags & NODE_TYPEMASK)>>NODE_TYPESHIFT)) #define nd_set_type(n,t) \ - RNODE(n)->flags=((RNODE(n)->flags&~NODE_TYPEMASK)|((((unsigned long)(t))<<NODE_TYPESHIFT)&NODE_TYPEMASK)) + (n)->flags=(((n)->flags&~NODE_TYPEMASK)|((((unsigned long)(t))<<NODE_TYPESHIFT)&NODE_TYPEMASK)) #define NODE_LSHIFT (NODE_TYPESHIFT+7) #define NODE_LMASK (((SIGNED_VALUE)1<<(sizeof(VALUE)*CHAR_BIT-NODE_LSHIFT))-1) -#define nd_line(n) (int)(((SIGNED_VALUE)RNODE(n)->flags)>>NODE_LSHIFT) +#define nd_line(n) (int)(((SIGNED_VALUE)(n)->flags)>>NODE_LSHIFT) #define nd_set_line(n,l) \ - RNODE(n)->flags=((RNODE(n)->flags&~((VALUE)(-1)<<NODE_LSHIFT))|((VALUE)((l)&NODE_LMASK)<<NODE_LSHIFT)) -#define nd_column(n) (int)(RNODE(n)->nd_location & 0xffff) + (n)->flags=(((n)->flags&~((VALUE)(-1)<<NODE_LSHIFT))|((VALUE)((l)&NODE_LMASK)<<NODE_LSHIFT)) +#define nd_column(n) (int)((n)->nd_location & 0xffff) #define nd_set_column(n, v) \ - RNODE(n)->nd_location = (RNODE(n)->nd_location & ~0xffff) | ((v) > 0xffff ? 0xffff : ((unsigned int)(v)) & 0xffff) + (n)->nd_location = ((n)->nd_location & ~0xffff) | ((v) > 0xffff ? 0xffff : ((unsigned int)(v)) & 0xffff) -#define nd_lineno(n) (int)((RNODE(n)->nd_location >> 16) & 0xffff) +#define nd_lineno(n) (int)(((n)->nd_location >> 16) & 0xffff) #define nd_set_lineno(n, v) \ - RNODE(n)->nd_location = (RNODE(n)->nd_location & ~0xffff0000) | (((v) > 0xffff ? 0xffff : ((unsigned int)(v)) & 0xffff) << 16) + (n)->nd_location = ((n)->nd_location & ~0xffff0000) | (((v) > 0xffff ? 0xffff : ((unsigned int)(v)) & 0xffff) << 16) #define nd_head u1.node #define nd_alen u2.argc -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/