mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* node.h (NODE_ATTRASGN): new node, assignment to attribute.
[ruby-core:00637]. * eval.c (is_defined, rb_eval): ditto. * parse.y (attrset, node_assign): ditto. * string.c (rb_str_substr): tail sharing. [ruby-core:00650] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3160 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
3a20ed532b
commit
86db656415
5 changed files with 45 additions and 3 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
Tue Dec 17 19:29:45 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||
|
||||
* node.h (NODE_ATTRASGN): new node, assignment to attribute.
|
||||
[ruby-core:00637].
|
||||
|
||||
* eval.c (is_defined, rb_eval): ditto.
|
||||
|
||||
* parse.y (attrset, node_assign): ditto.
|
||||
|
||||
* string.c (rb_str_substr): tail sharing. [ruby-core:00650]
|
||||
|
||||
Tue Dec 17 04:03:45 2002 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* lib/open-uri.rb: new file.
|
||||
|
|
18
eval.c
18
eval.c
|
@ -1881,6 +1881,7 @@ is_defined(self, node, buf)
|
|||
goto check_bound;
|
||||
|
||||
case NODE_CALL:
|
||||
case NODE_ATTRASGN:
|
||||
PUSH_TAG(PROT_NONE);
|
||||
if ((state = EXEC_TAG()) == 0) {
|
||||
val = rb_eval(self, node->nd_recv);
|
||||
|
@ -2742,6 +2743,23 @@ rb_eval(self, n)
|
|||
rb_eval(self, node->nd_body));
|
||||
break;
|
||||
|
||||
case NODE_ATTRASGN:
|
||||
{
|
||||
VALUE recv;
|
||||
int argc; VALUE *argv; /* used in SETUP_ARGS */
|
||||
TMP_PROTECT;
|
||||
|
||||
BEGIN_CALLARGS;
|
||||
recv = rb_eval(self, node->nd_recv);
|
||||
SETUP_ARGS(node->nd_args);
|
||||
END_CALLARGS;
|
||||
|
||||
SET_CURRENT_SOURCE();
|
||||
rb_call(CLASS_OF(recv),recv,node->nd_mid,argc,argv,0);
|
||||
result = argv[argc-1];
|
||||
}
|
||||
break;
|
||||
|
||||
case NODE_CALL:
|
||||
{
|
||||
VALUE recv;
|
||||
|
|
2
node.h
2
node.h
|
@ -123,6 +123,7 @@ enum node_type {
|
|||
NODE_MEMO,
|
||||
NODE_IFUNC,
|
||||
NODE_DSYM,
|
||||
NODE_ATTRASGN,
|
||||
NODE_LAST
|
||||
};
|
||||
|
||||
|
@ -332,6 +333,7 @@ typedef struct RNode {
|
|||
#define NEW_POSTEXE() rb_node_newnode(NODE_POSTEXE,0,0,0)
|
||||
#define NEW_DMETHOD(b) rb_node_newnode(NODE_DMETHOD,0,0,b)
|
||||
#define NEW_BMETHOD(b) rb_node_newnode(NODE_BMETHOD,0,0,b)
|
||||
#define NEW_ATTRASGN(r,m,a) rb_node_newnode(NODE_ATTRASGN,r,m,a)
|
||||
|
||||
#define NOEX_PUBLIC 0
|
||||
#define NOEX_NOSUPER 1
|
||||
|
|
3
parse.y
3
parse.y
|
@ -4705,7 +4705,7 @@ attrset(recv, id)
|
|||
ID id;
|
||||
{
|
||||
value_expr(recv);
|
||||
return NEW_CALL(recv, rb_id_attrset(id), 0);
|
||||
return NEW_ATTRASGN(recv, rb_id_attrset(id), 0);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -4765,6 +4765,7 @@ node_assign(lhs, rhs)
|
|||
lhs->nd_value = rhs;
|
||||
break;
|
||||
|
||||
case NODE_ATTRASGN:
|
||||
case NODE_CALL:
|
||||
lhs->nd_args = arg_add(lhs->nd_args, rhs);
|
||||
break;
|
||||
|
|
14
string.c
14
string.c
|
@ -474,8 +474,18 @@ rb_str_substr(str, beg, len)
|
|||
}
|
||||
if (len == 0) return rb_str_new5(str,0,0);
|
||||
|
||||
str2 = rb_str_new5(str,RSTRING(str)->ptr+beg, len);
|
||||
OBJ_INFECT(str2, str);
|
||||
if (len > sizeof(struct RString)/2 &&
|
||||
beg + len == RSTRING(str)->len &&
|
||||
!FL_TEST(str, STR_ASSOC)) {
|
||||
if (!FL_TEST(str, ELTS_SHARED)) str = rb_str_new4(str);
|
||||
str2 = rb_str_new3(str);
|
||||
RSTRING(str2)->ptr += beg;
|
||||
RSTRING(str2)->len = len;
|
||||
}
|
||||
else {
|
||||
str2 = rb_str_new5(str, RSTRING(str)->ptr+beg, len);
|
||||
OBJ_INFECT(str2, str);
|
||||
}
|
||||
|
||||
return str2;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue